chore(main): release 0.16.0 (#70) #72
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
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "scripts/**" | |
| - "*.md" | |
| - "docs/**" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version tag for manual build (e.g., v0.2.0)" | |
| required: true | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| BINARY_NAME: hcpctl | |
| jobs: | |
| release-please: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' | |
| outputs: | |
| release_created: ${{ steps.release.outputs.release_created }} | |
| tag_name: ${{ steps.release.outputs.tag_name }} | |
| steps: | |
| - name: Release Please | |
| id: release | |
| uses: googleapis/release-please-action@v4 | |
| with: | |
| release-type: rust | |
| build: | |
| name: Build ${{ matrix.target }} | |
| needs: release-please | |
| # always() is required to evaluate the condition even when release-please is skipped (workflow_dispatch). | |
| # Without it, this job would be auto-skipped due to skipped dependency. | |
| if: | | |
| always() && | |
| (needs.release-please.outputs.release_created == 'true' || github.event_name == 'workflow_dispatch') | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| platform: linux_amd64 | |
| - target: x86_64-unknown-linux-musl | |
| os: ubuntu-latest | |
| platform: linux_amd64_musl | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| platform: linux_arm64 | |
| use-cross: true | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| platform: macos_amd64 | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| platform: macos_arm64 | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| platform: windows_amd64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install musl tools (Linux musl) | |
| if: matrix.target == 'x86_64-unknown-linux-musl' | |
| run: sudo apt-get update && sudo apt-get install -y musl-tools | |
| - name: Install cross (ARM64) | |
| if: matrix.use-cross | |
| run: cargo install cross | |
| - name: Build (cross) | |
| if: matrix.use-cross | |
| run: cross build --release --target ${{ matrix.target }} | |
| - name: Build (cargo) | |
| if: ${{ !matrix.use-cross }} | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Prepare package | |
| shell: bash | |
| run: | | |
| VERSION="${{ needs.release-please.outputs.tag_name || github.event.inputs.version }}" | |
| mkdir -p dist package | |
| if [[ "${{ matrix.platform }}" == windows_* ]]; then | |
| cp "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe" "package/${{ env.BINARY_NAME }}.exe" | |
| PACKAGE_NAME="${{ env.BINARY_NAME }}_${VERSION}_${{ matrix.platform }}.zip" | |
| (cd package && 7z a -tzip "../dist/${PACKAGE_NAME}" "${{ env.BINARY_NAME }}.exe") | |
| else | |
| cp "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}" "package/${{ env.BINARY_NAME }}" | |
| chmod +x "package/${{ env.BINARY_NAME }}" | |
| PACKAGE_NAME="${{ env.BINARY_NAME }}_${VERSION}_${{ matrix.platform }}.tar.gz" | |
| (cd package && tar -czf "../dist/${PACKAGE_NAME}" "${{ env.BINARY_NAME }}") | |
| fi | |
| echo "ARTIFACT_NAME=${PACKAGE_NAME}" >> $GITHUB_ENV | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: dist/${{ env.ARTIFACT_NAME }} | |
| upload-release: | |
| name: Upload Release Assets | |
| needs: [release-please, build] | |
| runs-on: ubuntu-latest | |
| # always() needed for same reason as build job - release-please may be skipped | |
| if: | | |
| always() && | |
| needs.build.result == 'success' && | |
| (needs.release-please.outputs.release_created == 'true' || github.event_name == 'workflow_dispatch') | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Generate SHA256SUMS | |
| run: | | |
| cd dist | |
| sha256sum * > SHA256SUMS | |
| cat SHA256SUMS | |
| - name: Import GPG key | |
| if: ${{ vars.GPG_SIGNING_ENABLED == 'true' }} | |
| env: | |
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
| run: | | |
| echo "$GPG_PRIVATE_KEY" | gpg --batch --import | |
| - name: Sign SHA256SUMS | |
| if: ${{ vars.GPG_SIGNING_ENABLED == 'true' }} | |
| env: | |
| GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| run: | | |
| cd dist | |
| gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" --local-user "$GPG_KEY_ID" --detach-sign --output SHA256SUMS.sig SHA256SUMS | |
| - name: Upload to GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ needs.release-please.outputs.tag_name || github.event.inputs.version }} | |
| files: dist/* |