From 4edd504cb60397cfe143607ef5db8784598cbd06 Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Thu, 11 Jul 2024 08:41:13 +0000 Subject: [PATCH] ci: pin stable in semver-checks and updates weekly --- .../workflows/cron-weekly-update-stable.yml | 40 +++++++++++++++++++ .github/workflows/semver-checks.yml | 8 +++- .github/workflows/stable-version | 1 + 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cron-weekly-update-stable.yml create mode 100644 .github/workflows/stable-version diff --git a/.github/workflows/cron-weekly-update-stable.yml b/.github/workflows/cron-weekly-update-stable.yml new file mode 100644 index 000000000..df6dfd487 --- /dev/null +++ b/.github/workflows/cron-weekly-update-stable.yml @@ -0,0 +1,40 @@ +name: Update Stable rustc +on: + schedule: + - cron: "0 0 * * 5" # runs every Friday at 00:00 (generally rust releases on Thursday) + workflow_dispatch: # allows manual triggering +jobs: + format: + name: Update stable rustc + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Update semver-checks.yml to use latest stable + run: | + set -x + # Extract the version of the compiler dtolnay/rust-toolchain gives us. + STABLE_VERSION=$(rustc --version | sed -ne 's/^rustc //p' | cut -d ' ' -f1) + # Update the stable version in the reference file. + echo "${STABLE_VERSION}" > ./.github/workflows/stable-version + echo "stable_version=${STABLE_VERSION}" >> $GITHUB_ENV + # If somehow the stable version has not changed. In this case don't make an empty PR. + if ! git diff --exit-code > /dev/null; then + echo "Updated stable. Opening PR." + echo "changes_made=true" >> $GITHUB_ENV + else + echo "Attempted to update stable but the latest-stable date did not change. Not opening any PR." + echo "changes_made=false" >> $GITHUB_ENV + fi + - name: Create Pull Request + if: env.changes_made == 'true' + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.APOELSTRA_CREATE_PR_TOKEN }} + author: Update Stable Rustc Bot + committer: Update Stable Rustc Bot + title: Automated weekly update to rustc stable (to ${{ env.stable_version }}) + body: | + Automated update to Github CI workflow `semver-checks.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action + commit-message: Automated update to Github CI to rustc stable-${{ env.stable_version }} + branch: create-pull-request/weekly-stable-update diff --git a/.github/workflows/semver-checks.yml b/.github/workflows/semver-checks.yml index 166200585..b0eff52fe 100644 --- a/.github/workflows/semver-checks.yml +++ b/.github/workflows/semver-checks.yml @@ -5,7 +5,7 @@ name: Check semver breaks jobs: PR: - name: PR Semver - nightly toolchain + name: PR Semver - stable toolchain runs-on: ubuntu-latest strategy: fail-fast: false @@ -16,6 +16,9 @@ jobs: fetch-depth: 0 # we need full history for cargo semver-checks - name: "Install Rustup" uses: dtolnay/rust-toolchain@stable + - name: "Select stable-version" + run: | + rustup default $(cat ./.github/workflows/stable-version) - name: "Install cargo-binstall" uses: cargo-bins/cargo-binstall@main - name: "Binstall cargo-semver-checks" @@ -50,6 +53,9 @@ jobs: uses: actions/checkout@v4 - name: "Install Rustup" uses: dtolnay/rust-toolchain@stable + - name: "Select stable-version" + run: | + rustup default $(cat ./.github/workflows/stable-version) - name: "Install cargo-binstall" uses: cargo-bins/cargo-binstall@main - name: "Binstall cargo-semver-checks" diff --git a/.github/workflows/stable-version b/.github/workflows/stable-version new file mode 100644 index 000000000..b3a8c61e6 --- /dev/null +++ b/.github/workflows/stable-version @@ -0,0 +1 @@ +1.79.0