Skip to content

Commit

Permalink
ci: Use composite Rust version action (#320)
Browse files Browse the repository at this point in the history
* ci: Use composite Rust version action

* Prep for merge
  • Loading branch information
samuelburnham authored Nov 7, 2024
1 parent 3ad34ea commit dbadf57
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions .github/workflows/rust-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,17 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Parse rust-toolchain.toml
run: echo "TOOLCHAIN_VERSION=$(rustup show | grep rustc | awk -F'[()]| ' '{ print $(NF-1) }')" | tee -a $GITHUB_ENV
working-directory: ${{ github.workspace }}/${{ matrix.package }}
- name: Get latest nightly Rust version
run: |
echo "RUST_VERSION=$(rustup check | grep nightly | awk -F'[()]| ' '{print $(NF-1)}')" | tee -a $GITHUB_ENV
- name: Compare Rust versions
id: compare-versions
run: |
if [[ $(printf '%s\n' "$TOOLCHAIN_VERSION" "$RUST_VERSION" | sort -V | head -n 1) != "$RUST_VERSION" ]]; then
echo "outdated=true" | tee -a $GITHUB_OUTPUT
fi
working-directory: ${{ github.workspace }}/${{ matrix.package }}
- name: Update Cargo.toml
if: steps.compare-versions.outputs.outdated == 'true'
run: |
sed -i 's/channel = .*/channel = "nightly-${{ env.RUST_VERSION }}"/' rust-toolchain.toml
working-directory: ${{ github.workspace }}/${{ matrix.package }}
- uses: actions/checkout@v4
with:
repository: argumentcomputer/ci-workflows
path: ci-workflows
- uses: ./ci-workflows/.github/actions/rust-version
id: rust-version
with:
toolchain: nightly
path: ${{ matrix.package }}
- uses: tibdex/github-app-token@v2
if: steps.compare-versions.outputs.outdated == 'true'
if: steps.rust-version.outputs.outdated == 'true'
id: generate-token
with:
app_id: ${{ secrets.TOKEN_APP_ID }}
Expand All @@ -46,11 +37,11 @@ jobs:
with:
token: ${{ steps.generate-token.outputs.token }}
branch: "ci-update-rust-version-${{ matrix.package }}"
title: "chore: Update `${{ matrix.package }}` Rust version to `nightly-${{ env.RUST_VERSION }}`"
commit-message: "chore: Update `${{ matrix.package }}` Rust version to `nightly-${{ env.RUST_VERSION }}`"
title: "chore: Update `${{ matrix.package }}` Rust version to `nightly-${{ steps.rust-version.outputs.new-version }}`"
commit-message: "chore: Update `${{ matrix.package }}` Rust version to `nightly-${{ steps.rust-version.outputs.new-version }}`"
labels: "automated-issue"
reviewers: "tchataigner, wwared, storojs72, huitseeker, samuelburnham"
body: |
This is an automated PR updating the `${{ matrix.package }}` Rust version from `nightly-${{ env.TOOLCHAIN_VERSION }}` to `nightly-${{ env.RUST_VERSION }}`
This is an automated PR updating the `${{ matrix.package }}` Rust version from `nightly-${{ steps.rust-version.outputs.old-version }}` to `nightly-${{ steps.rust-version.outputs.new-version }}`
Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

0 comments on commit dbadf57

Please sign in to comment.