|
| 1 | +name: Check Supported Rust Versions |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: "0 17 * * *" |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +jobs: |
| 8 | + check-rust-eol: |
| 9 | + permissions: |
| 10 | + contents: read |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + target: ${{ steps.parse.outputs.target }} |
| 14 | + timeout-minutes: 2 |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + # Perform a GET request to endoflife.date for the Rust language. The response |
| 18 | + # contains all Rust releases; we're interested in the 2nd index (antepenultimate). |
| 19 | + - name: Fetch officially supported Rust versions |
| 20 | + uses: JamesIves/fetch-api-data-action@396ebea7d13904824f85b892b1616985f847301c |
| 21 | + with: |
| 22 | + endpoint: https://endoflife.date/api/rust.json |
| 23 | + configuration: '{ "method": "GET" }' |
| 24 | + debug: true |
| 25 | + # Parse the response JSON and insert into environment variables for the next step. |
| 26 | + # We use the antepenultimate (third most recent) version as our target. |
| 27 | + - name: Parse officially supported Rust versions |
| 28 | + id: parse |
| 29 | + run: | |
| 30 | + echo "target=${{ fromJSON(env.fetch-api-data)[2].cycle }}" >> $GITHUB_OUTPUT |
| 31 | +
|
| 32 | + create-prs: |
| 33 | + permissions: |
| 34 | + contents: write |
| 35 | + pull-requests: write |
| 36 | + needs: check-rust-eol |
| 37 | + runs-on: ubuntu-latest |
| 38 | + env: |
| 39 | + officialTargetVersion: ${{ needs.check-rust-eol.outputs.target }} |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Get current Rust version |
| 44 | + id: rust-versions |
| 45 | + run: cat ./.github/variables/rust-versions.env >> $GITHUB_OUTPUT |
| 46 | + |
| 47 | + - name: Update rust-versions.env and Cargo.toml |
| 48 | + if: steps.rust-versions.outputs.target != env.officialTargetVersion |
| 49 | + id: update-rust-versions |
| 50 | + run: | |
| 51 | + # Update the versions file |
| 52 | + sed -i -e "s#target=[^ ]*#target=${{ env.officialTargetVersion }}#g" \ |
| 53 | + ./.github/variables/rust-versions.env |
| 54 | +
|
| 55 | + # Update Cargo.toml rust-version field |
| 56 | + sed -i -e "s#rust-version = \"[^\"]*\"#rust-version = \"${{ env.officialTargetVersion }}.0\"#g" \ |
| 57 | + ./eventsource-client/Cargo.toml |
| 58 | +
|
| 59 | + - name: Create pull request |
| 60 | + if: steps.update-rust-versions.outcome == 'success' |
| 61 | + uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 |
| 62 | + with: |
| 63 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + add-paths: | |
| 65 | + .github/variables/rust-versions.env |
| 66 | + eventsource-client/Cargo.toml |
| 67 | + branch: "launchdarklyreleasebot/update-to-rust${{ env.officialTargetVersion }}" |
| 68 | + author: "LaunchDarklyReleaseBot <LaunchDarklyReleaseBot@launchdarkly.com>" |
| 69 | + committer: "LaunchDarklyReleaseBot <LaunchDarklyReleaseBot@launchdarkly.com>" |
| 70 | + title: "fix: Bump MSRV from ${{ steps.rust-versions.outputs.target }} to ${{ env.officialTargetVersion }}" |
| 71 | + body: | |
| 72 | + - [ ] I have triggered CI on this PR (either close & reopen this PR in Github UI, or `git commit -m "run ci" --allow-empty && git push`) |
0 commit comments