|
| 1 | +name: Check Supported Go Versions |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: "0 17 * * *" |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +jobs: |
| 8 | + check-go-eol: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + outputs: |
| 11 | + latest: ${{ steps.parse.outputs.latest }} |
| 12 | + penultimate: ${{ steps.parse.outputs.penultimate }} |
| 13 | + timeout-minutes: 2 |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + # Perform a GET request to endoflife.date for the Go language. The response |
| 17 | + # contains all Go releases; we're interested in the 0'th and 1'th (latest and penultimate.) |
| 18 | + - name: Fetch officially supported Go versions |
| 19 | + uses: JamesIves/fetch-api-data-action@396ebea7d13904824f85b892b1616985f847301c |
| 20 | + with: |
| 21 | + endpoint: https://endoflife.date/api/go.json |
| 22 | + configuration: '{ "method": "GET" }' |
| 23 | + debug: true |
| 24 | + # Parse the response JSON and insert into environment variables for the next step. |
| 25 | + - name: Parse officially supported Go versions |
| 26 | + id: parse |
| 27 | + run: | |
| 28 | + echo "latest=${{ fromJSON(env.fetch-api-data)[0].cycle }}" >> $GITHUB_OUTPUT |
| 29 | + echo "penultimate=${{ fromJSON(env.fetch-api-data)[1].cycle }}" >> $GITHUB_OUTPUT |
| 30 | +
|
| 31 | +
|
| 32 | + create-prs: |
| 33 | + permissions: |
| 34 | + contents: write |
| 35 | + pull-requests: write |
| 36 | + needs: check-go-eol |
| 37 | + runs-on: ubuntu-latest |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + branch: ["v4"] |
| 41 | + fail-fast: false |
| 42 | + env: |
| 43 | + officialLatestVersion: ${{ needs.check-go-eol.outputs.latest }} |
| 44 | + officialPenultimateVersion: ${{ needs.check-go-eol.outputs.penultimate }} |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + with: |
| 48 | + ref: ${{ matrix.branch }} |
| 49 | + |
| 50 | + - name: Get current Go versions |
| 51 | + id: go-versions |
| 52 | + run: cat ./.github/variables/go-versions.env > $GITHUB_OUTPUT |
| 53 | + |
| 54 | + - name: Update go-versions.env and README.md |
| 55 | + if: steps.go-versions.outputs.latest != env.officialLatestVersion |
| 56 | + id: update-go-versions |
| 57 | + run: | |
| 58 | + sed -i -e "s#latest=[^ ]*#latest=${{ env.officialLatestVersion }}#g" \ |
| 59 | + -e "s#penultimate=[^ ]*#penultimate=${{ env.officialPenultimateVersion }}#g" \ |
| 60 | + ./.github/variables/go-versions.env |
| 61 | +
|
| 62 | + - name: Create pull request |
| 63 | + if: steps.update-go-versions.outcome == 'success' |
| 64 | + uses: peter-evans/create-pull-request@v6 |
| 65 | + with: |
| 66 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + add-paths: | |
| 68 | + .github/variables/go-versions.env |
| 69 | + branch: "launchdarklyreleasebot/update-to-go${{ env.officialLatestVersion }}-${{ matrix.branch }}" |
| 70 | + author: "LaunchDarklyReleaseBot <LaunchDarklyReleaseBot@launchdarkly.com>" |
| 71 | + committer: "LaunchDarklyReleaseBot <LaunchDarklyReleaseBot@launchdarkly.com>" |
| 72 | + labels: ${{ matrix.branch }} |
| 73 | + title: "ci: bump tested Go versions to ${{ env.officialLatestVersion }} and ${{ env.officialPenultimateVersion }}" |
| 74 | + commit-message: "Bumps from Go ${{ steps.go-versions.outputs.latest }} -> ${{ env.officialLatestVersion }} and ${{ steps.go-versions.outputs.penultimate }} -> ${{ env.officialPenultimateVersion }}." |
| 75 | + body: | |
| 76 | + - [ ] 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