v0.1.2 #10
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
| name: Publish Binaries | |
| on: | |
| # This action runs whenever a release is published | |
| release: | |
| types: | |
| - published | |
| # Run on pull requests to publish binaries to pull request workflow runs | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - crates/** | |
| - Cargo.* | |
| - Makefile.toml | |
| - rust-toolchain.toml | |
| - .github/workflows/publish.yaml | |
| permissions: | |
| contents: read # Default token to read | |
| jobs: | |
| upload-artifact: | |
| if: ${{ github.repository_owner == 'edera-dev' && (github.event_name == 'release' || github.event.pull_request.head.repo.full_name == github.repository) }} | |
| name: Publish Binaries | |
| permissions: | |
| contents: write # Needed to publish binary | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - { os: linux, arch: x86_64, libc: musl, static: true, on: ubuntu-latest } | |
| - { os: linux, arch: x86_64, libc: gnu, static: true, on: ubuntu-latest } | |
| - { os: linux, arch: x86_64, libc: gnu, static: false, on: ubuntu-latest } | |
| env: | |
| TARGET_OS: '${{ matrix.platform.os }}' | |
| TARGET_ARCH: '${{ matrix.platform.arch }}' | |
| TARGET_LIBC: '${{ matrix.platform.libc }}' | |
| STATIC_BINARY: '${{ matrix.platform.static }}' | |
| runs-on: '${{ matrix.platform.on }}' | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@5d458579430fc14a04a08a1e7d3694f545e91ce6 # zizmor: ignore[stale-action-refs] -- pinned to stable branch | |
| - name: Install cargo-make | |
| run: cargo install cargo-make | |
| - name: 'Build binaries' | |
| run: cargo make --profile release build | |
| - name: 'Set platform name' | |
| id: name | |
| run: | | |
| platform="${TARGET_OS}-${TARGET_ARCH}-${TARGET_LIBC}" | |
| # Adding -static to a musl binary name is redundant | |
| [ "${STATIC_BINARY}" = "true" ] && [ "${TARGET_LIBC}" != "musl" ] && platform="${platform}-static" | |
| echo "platform=$platform" >> $GITHUB_OUTPUT | |
| - name: 'Assemble capsudo executables' | |
| run: | | |
| tag_name="${TAG_NAME}" | |
| [ -z $tag_name ] && tag_name="${DEFAULT_BRANCH}" | |
| export CAPSUDO_TAG_NAME="${tag_name}" | |
| export CAPSUDO_PLATFORM | |
| export CAPSUDO_RELEASE_DIR='target/*/release' | |
| cargo make --profile release assemble-release-assets | |
| env: | |
| TAG_NAME: '${{ github.event.release.tag_name }}' | |
| DEFAULT_BRANCH: '${{ github.event.repository.default_branch }}' | |
| CAPSUDO_PLATFORM: '${{ steps.name.outputs.platform }}' | |
| - name: 'Upload capsudo binaries to workflow run' | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: capsudo-${{ steps.name.outputs.platform }} | |
| path: | | |
| target/assets/* | |
| - name: generate cultivator token | |
| if: ${{ github.event_name == 'release' }} | |
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | |
| id: generate-token | |
| with: | |
| app-id: "${{ secrets.EDERA_CULTIVATION_APP_ID }}" | |
| private-key: "${{ secrets.EDERA_CULTIVATION_APP_PRIVATE_KEY }}" | |
| - name: 'Upload all release artifacts' | |
| if: ${{ github.event_name == 'release' }} | |
| run: | | |
| export CAPSUDO_TAG_NAME="${TAG_NAME}" | |
| cargo make --profile release upload-release-assets | |
| env: | |
| GITHUB_TOKEN: "${{ steps.generate-token.outputs.token }}" | |
| TAG_NAME: '${{ github.event.release.tag_name }}' |