chore(deps): bump the cargo-dependencies group with 5 updates #293
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
| # This file is based on the cargo-dist GitHub Actions template. | |
| # It publishes artifacts to GitHub Releases when a version bump lands on the | |
| # default branch, building artifacts before cargo-dist uploads them to a single | |
| # validated draft release and publishes it. | |
| name: Release | |
| permissions: | |
| contents: read | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| paths: | |
| - Cargo.toml | |
| - dist-workspace.toml | |
| - .github/workflows/release.yml | |
| concurrency: | |
| group: dist-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| plan: | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| val: ${{ steps.plan.outputs.manifest }} | |
| tag: ${{ steps.release_meta.outputs.tag }} | |
| tag_flag: ${{ steps.release_meta.outputs.tag_flag }} | |
| publishing: ${{ steps.release_meta.outputs.publishing }} | |
| release_state: ${{ steps.release_meta.outputs.release_state }} | |
| tag_exists: ${{ steps.release_meta.outputs.tag_exists }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| submodules: recursive | |
| - id: release_meta | |
| shell: bash | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| BEFORE_SHA: ${{ github.event.before }} | |
| REF_NAME: ${{ github.ref_name }} | |
| TARGET_SHA: ${{ github.sha }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPO: ${{ github.repository }} | |
| run: | | |
| set -euo pipefail | |
| current_version="$( | |
| awk ' | |
| /^[[:space:]]*\[package\][[:space:]]*$/ { in_package = 1; next } | |
| /^[[:space:]]*\[/ { in_package = 0 } | |
| in_package && /^[[:space:]]*version[[:space:]]*=[[:space:]]*/ { print $3; exit } | |
| ' Cargo.toml | tr -d '"' | |
| )" | |
| [[ -n "$current_version" ]] || { | |
| echo "failed to determine package version from Cargo.toml" >&2 | |
| exit 1 | |
| } | |
| [[ "$current_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { | |
| echo "release automation only supports Cargo.toml versions in X.Y.Z format, found: $current_version" >&2 | |
| exit 1 | |
| } | |
| tag="v$current_version" | |
| publishing=false | |
| previous_version="" | |
| release_state="missing" | |
| tag_exists=false | |
| tag_commit="" | |
| if gh release view "$tag" -R "$GH_REPO" --json isDraft > release-state.json 2>/dev/null; then | |
| if jq -e '.isDraft' release-state.json > /dev/null; then | |
| release_state="draft" | |
| else | |
| release_state="published" | |
| fi | |
| fi | |
| if git rev-parse -q --verify "refs/tags/$tag" > /dev/null; then | |
| tag_exists=true | |
| tag_commit="$(git rev-list -n 1 "refs/tags/$tag")" | |
| if [[ "$release_state" == "missing" ]]; then | |
| release_state="tag-only" | |
| fi | |
| fi | |
| case "$EVENT_NAME" in | |
| push) | |
| if [[ -n "${BEFORE_SHA:-}" && "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]]; then | |
| if previous_manifest="$(git show "$BEFORE_SHA:Cargo.toml" 2>/dev/null)"; then | |
| previous_version="$( | |
| printf '%s\n' "$previous_manifest" | awk ' | |
| /^[[:space:]]*\[package\][[:space:]]*$/ { in_package = 1; next } | |
| /^[[:space:]]*\[/ { in_package = 0 } | |
| in_package && /^[[:space:]]*version[[:space:]]*=[[:space:]]*/ { print $3; exit } | |
| ' | tr -d '"' | |
| )" | |
| fi | |
| fi | |
| if [[ "$previous_version" != "$current_version" ]]; then | |
| if [[ "$release_state" == "published" ]]; then | |
| echo "release $tag already exists; skipping publish" | |
| elif [[ "$tag_exists" == "true" && "$tag_commit" != "$TARGET_SHA" ]]; then | |
| echo "tag $tag already points to $tag_commit, expected $TARGET_SHA" >&2 | |
| exit 1 | |
| else | |
| publishing=true | |
| fi | |
| fi | |
| ;; | |
| workflow_dispatch) | |
| if [[ "${REF_NAME:-}" != "main" && "${REF_NAME:-}" != "master" ]]; then | |
| echo "::notice::manual release runs only publish from main or master; selected ref: ${REF_NAME:-unknown}" | |
| elif [[ "$release_state" == "published" ]]; then | |
| echo "release $tag already exists; skipping publish" | |
| elif [[ "$tag_exists" == "true" && "$tag_commit" != "$TARGET_SHA" ]]; then | |
| echo "tag $tag already points to $tag_commit, expected $TARGET_SHA" >&2 | |
| exit 1 | |
| else | |
| publishing=true | |
| fi | |
| ;; | |
| esac | |
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
| echo "tag_flag=--tag=$tag" >> "$GITHUB_OUTPUT" | |
| echo "publishing=$publishing" >> "$GITHUB_OUTPUT" | |
| echo "release_state=$release_state" >> "$GITHUB_OUTPUT" | |
| echo "tag_exists=$tag_exists" >> "$GITHUB_OUTPUT" | |
| - name: Install dist | |
| shell: bash | |
| run: | | |
| curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.4/cargo-dist-installer.sh | sh | |
| - name: Cache dist | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: cargo-dist-cache | |
| path: ~/.cargo/bin/dist | |
| - id: plan | |
| env: | |
| TAG: ${{ steps.release_meta.outputs.tag }} | |
| PUBLISHING: ${{ steps.release_meta.outputs.publishing }} | |
| run: | | |
| set -euo pipefail | |
| if [[ "${{ github.event_name }}" == "pull_request" || "$PUBLISHING" != "true" ]]; then | |
| dist plan --output-format=json --target=x86_64-unknown-linux-gnu > plan-dist-manifest.json | |
| else | |
| dist host --steps=create --tag="$TAG" --output-format=json > plan-dist-manifest.json | |
| fi | |
| echo "dist ran successfully" | |
| cat plan-dist-manifest.json | |
| echo "manifest=$(jq -c '.' plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" | |
| - name: Upload dist manifest | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: artifacts-plan-dist-manifest | |
| path: plan-dist-manifest.json | |
| create-release: | |
| needs: [plan, build-local-artifacts, build-global-artifacts] | |
| if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') }} | |
| runs-on: ubuntu-22.04 | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Create or reuse draft GitHub Release | |
| shell: bash | |
| env: | |
| GH_REPO: ${{ github.repository }} | |
| RELEASE_TAG: ${{ needs.plan.outputs.tag }} | |
| RELEASE_COMMIT: ${{ github.sha }} | |
| TAG_EXISTS: ${{ needs.plan.outputs.tag_exists }} | |
| PLAN_MANIFEST: ${{ needs.plan.outputs.val }} | |
| run: | | |
| set -euo pipefail | |
| printf '%s' "$PLAN_MANIFEST" > plan-dist-manifest.json | |
| title="$(jq -r '.announcement_title' plan-dist-manifest.json)" | |
| jq -r '.announcement_github_body' plan-dist-manifest.json > release-notes.md | |
| gh api --paginate --slurp \ | |
| "repos/$GH_REPO/releases?per_page=100" > release-pages.json | |
| matching_count="$( | |
| jq --arg tag "$RELEASE_TAG" \ | |
| '[.[][] | select(.tag_name == $tag)] | length' \ | |
| release-pages.json | |
| )" | |
| if [[ "$matching_count" -gt 1 ]]; then | |
| echo "multiple releases found for $RELEASE_TAG" >&2 | |
| exit 1 | |
| fi | |
| if [[ "$matching_count" -eq 1 ]]; then | |
| jq --arg tag "$RELEASE_TAG" \ | |
| '.[][] | select(.tag_name == $tag)' \ | |
| release-pages.json > matching-release.json | |
| if ! jq -e '.draft == true' matching-release.json > /dev/null; then | |
| echo "release $RELEASE_TAG was published after this workflow started" >&2 | |
| exit 1 | |
| fi | |
| draft_target="$(jq -r '.target_commitish' matching-release.json)" | |
| if [[ "$draft_target" != "$RELEASE_COMMIT" ]]; then | |
| echo "draft for $RELEASE_TAG targets $draft_target, expected $RELEASE_COMMIT" >&2 | |
| exit 1 | |
| fi | |
| echo "reusing draft release for $RELEASE_TAG" | |
| exit 0 | |
| fi | |
| args=( | |
| release | |
| create | |
| "$RELEASE_TAG" | |
| -R "$GH_REPO" | |
| --draft | |
| --title "$title" | |
| --notes-file release-notes.md | |
| ) | |
| if [[ "$TAG_EXISTS" != "true" ]]; then | |
| args+=(--target "$RELEASE_COMMIT") | |
| fi | |
| gh "${args[@]}" | |
| build-local-artifacts: | |
| name: build-local-artifacts (${{ join(matrix.targets, ', ') }}) | |
| needs: [plan] | |
| if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }} | |
| runs-on: ${{ matrix.runner }} | |
| container: ${{ matrix.container && matrix.container.image || null }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json | |
| permissions: | |
| attestations: write | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: enable windows longpaths | |
| run: | | |
| git config --global core.longpaths true | |
| - uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| submodules: recursive | |
| - name: Install Rust non-interactively if not already installed | |
| if: ${{ matrix.container }} | |
| run: | | |
| if ! command -v cargo > /dev/null 2>&1; then | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| fi | |
| - name: Install dist | |
| run: ${{ matrix.install_dist.run }} | |
| - name: Fetch local artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: artifacts-* | |
| path: target/distrib/ | |
| merge-multiple: true | |
| - name: Install dependencies | |
| run: | | |
| ${{ matrix.packages_install }} | |
| - name: Build artifacts | |
| shell: bash | |
| env: | |
| TAG_FLAG: ${{ needs.plan.outputs.tag_flag }} | |
| run: | | |
| set -euo pipefail | |
| dist build $TAG_FLAG --target=${{ join(matrix.targets, ',') }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json | |
| echo "dist ran successfully" | |
| - name: Attest | |
| uses: actions/attest-build-provenance@v4 | |
| with: | |
| subject-path: "target/distrib/*${{ join(matrix.targets, ',') }}*" | |
| - id: cargo-dist | |
| name: Post-build | |
| shell: bash | |
| run: | | |
| echo "paths<<EOF" >> "$GITHUB_OUTPUT" | |
| dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| cp dist-manifest.json "$BUILD_MANIFEST_NAME" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: artifacts-build-local-${{ join(matrix.targets, '_') }} | |
| path: | | |
| ${{ steps.cargo-dist.outputs.paths }} | |
| ${{ env.BUILD_MANIFEST_NAME }} | |
| build-global-artifacts: | |
| needs: [plan, build-local-artifacts] | |
| if: ${{ always() && needs.plan.result == 'success' && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') && fromJson(needs.plan.outputs.val).ci.github.global_artifacts != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} | |
| runs-on: ubuntu-22.04 | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| submodules: recursive | |
| - name: Install cached dist | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: cargo-dist-cache | |
| path: ~/.cargo/bin/ | |
| - run: chmod +x ~/.cargo/bin/dist | |
| - name: Fetch local artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: artifacts-* | |
| path: target/distrib/ | |
| merge-multiple: true | |
| - id: cargo-dist | |
| shell: bash | |
| env: | |
| TAG_FLAG: ${{ needs.plan.outputs.tag_flag }} | |
| run: | | |
| set -euo pipefail | |
| dist build $TAG_FLAG --target=x86_64-unknown-linux-gnu --output-format=json --artifacts=global > dist-manifest.json | |
| echo "dist ran successfully" | |
| echo "paths<<EOF" >> "$GITHUB_OUTPUT" | |
| jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| cp dist-manifest.json "$BUILD_MANIFEST_NAME" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: artifacts-build-global | |
| path: | | |
| ${{ steps.cargo-dist.outputs.paths }} | |
| ${{ env.BUILD_MANIFEST_NAME }} | |
| host: | |
| needs: [plan, create-release, build-local-artifacts, build-global-artifacts] | |
| if: ${{ always() && needs.plan.result == 'success' && (needs.create-release.result == 'skipped' || needs.create-release.result == 'success') && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| submodules: recursive | |
| - name: Install cached dist | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: cargo-dist-cache | |
| path: ~/.cargo/bin/ | |
| - run: chmod +x ~/.cargo/bin/dist | |
| - name: Fetch artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: artifacts-* | |
| path: target/distrib/ | |
| merge-multiple: true | |
| - id: host | |
| shell: bash | |
| env: | |
| TAG_FLAG: ${{ needs.plan.outputs.tag_flag }} | |
| run: | | |
| set -euo pipefail | |
| [[ "$TAG_FLAG" =~ ^--tag=v[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1 | |
| dist host $TAG_FLAG --steps=upload --steps=release --steps=announce --output-format=json > dist-manifest.json | |
| echo "artifacts uploaded and released successfully" | |
| cat dist-manifest.json | |
| echo "manifest=$(jq -c '.' dist-manifest.json)" >> "$GITHUB_OUTPUT" | |
| - name: Upload dist manifest | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: artifacts-dist-manifest | |
| path: dist-manifest.json | |
| - name: Download GitHub Artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: artifacts-* | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Cleanup | |
| run: | | |
| rm -f artifacts/*-dist-manifest.json | |
| publish-release: | |
| needs: [plan, create-release, host] | |
| if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.create-release.result == 'skipped' || needs.create-release.result == 'success') && needs.host.result == 'success' }} | |
| runs-on: ubuntu-22.04 | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Publish GitHub Release | |
| shell: bash | |
| env: | |
| GH_REPO: ${{ github.repository }} | |
| RELEASE_TAG: ${{ needs.plan.outputs.tag }} | |
| run: | | |
| set -euo pipefail | |
| gh release edit "$RELEASE_TAG" -R "$GH_REPO" --draft=false --latest |