go-update #1056
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
| name: go-update | |
| on: | |
| schedule: | |
| - cron: "0 */4 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| go-update: | |
| runs-on: ubuntu-24.04 | |
| name: go-update | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | |
| with: | |
| token: ${{ secrets.GH_NSV }} | |
| - name: Setup Nix | |
| uses: ./.github/actions/setup-nix | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| cachix-token: ${{ secrets.GH_CACHIX }} | |
| - name: Detect Latest Go Versions | |
| run: | | |
| LATEST=$(nix run .#goscrape -- go-dev detect) | |
| PREV_MINOR="1.$(($(echo "$LATEST" | cut -d. -f2) - 1))" | |
| PREV=$(nix run .#goscrape -- go-dev detect "$PREV_MINOR") | |
| # The stable VERSION endpoint never reports release candidates, so | |
| # detect the latest pre-release separately to pick up a new minor's | |
| # rc (e.g. 1.27rc1) before it reaches GA. Duplicates are de-duped by | |
| # the existing manifest/PR checks below. | |
| PRE=$(nix run .#goscrape -- go-dev detect --include-prerelease) | |
| echo "GO_VERSIONS=$LATEST $PREV $PRE" >> $GITHUB_ENV | |
| - name: GPG Import | |
| uses: purpleclay/gpg-import-action@a39506c3eff9b02459e033e3551e556934f266fc # v0 | |
| with: | |
| key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Generate Manifests and Create PRs | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_NSV }} | |
| run: | | |
| for version in ${{ env.GO_VERSIONS }}; do | |
| manifest="manifests/go/${version}.nix" | |
| if [ -f "$manifest" ]; then | |
| echo "Manifest already exists for ${version}" | |
| continue | |
| fi | |
| branch="nix-go-${version}" | |
| # Skip if a PR already exists for this version | |
| if gh pr list --head "$branch" --state open --json number --jq 'length' | grep -q '[1-9]'; then | |
| echo "PR already exists for ${version}" | |
| continue | |
| fi | |
| nix run .#goscrape -- go-dev generate "$version" --output manifests/go | |
| git checkout -b "$branch" | |
| git add "$manifest" | |
| git commit -s -m "chore(go): generated nix manifest for go release ${version}" | |
| git push -u origin "$branch" | |
| gh pr create \ | |
| --title "chore(go): add go ${version} manifest" \ | |
| --body "Auto-generated nix manifest for Go release ${version}." \ | |
| --base main \ | |
| --head "$branch" | |
| gh pr merge --auto --squash "$branch" | |
| # Return to main for the next version | |
| git checkout main | |
| done |