CI: fix release workflow #28
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Workflow triggered on creation of a new tag: | |
| # - creates a release | |
| # - builds packages and uploads them to the release | |
| # | |
| # Reference: | |
| # https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/ | |
| name: release | |
| on: | |
| push: | |
| tags: | |
| - "[0-9]+.[0-9]+.[0-9]+" | |
| jobs: | |
| create-release: | |
| name: create-release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get the release version from the tag | |
| shell: bash | |
| run: | | |
| echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| echo "release version is: ${{ env.RELEASE_VERSION }}" | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| outputs: | |
| release_version: ${{ env.RELEASE_VERSION }} | |
| build-release: | |
| name: Build release | |
| needs: ['create-release'] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| build: | |
| - x86_64-pc-windows-msvc | |
| - x86_64-unknown-linux-gnu | |
| - x86_64-apple-darwin | |
| include: | |
| - build: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| - build: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| - build: x86_64-apple-darwin | |
| os: macos-15-intel | |
| target: x86_64-apple-darwin | |
| - build: aarch64-apple-darwin | |
| os: macos-latest | |
| target: aarch64-apple-darwin | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 1 | |
| - name: Build | |
| run: cargo build --verbose --target=${{ matrix.target }} --release | |
| - name: Package | |
| shell: bash | |
| run: | | |
| package="psa-update-${{ needs.create-release.outputs.release_version }}-${{ matrix.build }}" | |
| mkdir "$package" | |
| cp "README.md" "LICENCE.md" "$package" | |
| if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
| cp "target/${{ matrix.target }}/release/psa-update.exe" "$package" | |
| 7z a "$package.zip" "$package" | |
| certutil -hashfile "$package.zip" SHA256 > "$package.zip.sha256" | |
| echo "ASSET_PATH=$package.zip" >> $GITHUB_ENV | |
| echo "ASSET_CSUM_PATH=$package.zip.sha256" >> $GITHUB_ENV | |
| else | |
| cp "target/${{ matrix.target }}/release/psa-update" "$package" | |
| tar czf "$package.tar.gz" "$package" | |
| shasum -a 256 "$package.tar.gz" > "$package.tar.gz.sha256" | |
| echo "ASSET_PATH=$package.tar.gz" >> $GITHUB_ENV | |
| echo "ASSET_CSUM_PATH=$package.tar.gz.sha256" >> $GITHUB_ENV | |
| fi | |
| - name: Upload release archive | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| ${{ env.ASSET_PATH }} | |
| ${{ env.ASSET_CSUM_PATH }} |