Skip to content

Workflow file for this run

name: Build and package for release
on:
release:
types: [published]
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
env:
PRODUCT_NAME: CanIUse
PROJECT_PATH: ./src/CanIUse/Community.PowerToys.Run.Plugin.CanIUse
SLN_PATH: ./src/CanIUse/CanIUse.sln
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from release tag
id: extract_version
run: |
$version = '${{ github.event.release.tag_name }}'
echo "VERSION=$version" >> $env:GITHUB_ENV
shell: powershell
- name: Replace version token in plugin.json
run: |
(Get-Content '${{ env.PROJECT_PATH }}/plugin.json') -replace '\$\(Version\)', '${{ env.VERSION }}' | Set-Content '${{ env.PROJECT_PATH }}/plugin.json'
shell: powershell
- name: Package
run: |
dotnet pack ${{ env.SLN_PATH }} -p:Platform=x64 -p:Version=${{ env.VERSION }}
dotnet pack ${{ env.SLN_PATH }} -p:Platform=ARM64 -p:Version=${{ env.VERSION }}
- name: Upload x64 to Release Action
uses: Shopify/upload-to-release@v2.0.0
with:
name: ${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-x64.zip
path: ${{ env.PROJECT_PATH }}/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-x64.zip
content-type: application/zip
repo-token: ${{secrets.GITHUB_TOKEN}}
- name: Upload ARM64 to Release Action
uses: Shopify/upload-to-release@v2.0.0
with:
name: ${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-ARM64.zip
path: ${{ env.PROJECT_PATH }}/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-ARM64.zip
content-type: application/zip
repo-token: ${{secrets.GITHUB_TOKEN}}
# Step to calculate SHA256 for the two files
- name: Calculate SHA-256 Hash for x64 and ARM64
id: calculate_sha
run: |
$x64_hash = Get-FileHash -Path "${{ env.PROJECT_PATH }}/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-x64.zip" -Algorithm SHA256 | Select-Object -ExpandProperty Hash
$arm64_hash = Get-FileHash -Path "${{ env.PROJECT_PATH }}/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-ARM64.zip" -Algorithm SHA256 | Select-Object -ExpandProperty Hash
echo "x64_SHA=$x64_hash" >> $env:GITHUB_ENV
echo "ARM64_SHA=$arm64_hash" >> $env:GITHUB_ENV
shell: powershell
- name: update release
id: update_release
uses: tubone24/update_release@v1.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:
is_append_body: 1
body: |
## SHA-256 Hashes:
- **x64 Hash**: \`${{ env.x64_SHA }}\`
- **ARM64 Hash**: \`${{ env.ARM64_SHA }}\`