Release #64
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: Release | |
| on: | |
| repository_dispatch: | |
| types: [openapi-updated] | |
| schedule: | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| version_bump: | |
| description: 'patch | minor | major' | |
| required: false | |
| default: 'patch' | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| - name: Regenerate from spec | |
| run: go run ./tools/roxygen generate | |
| # Compare against the last RELEASED tag, never against the working tree. | |
| # "Did anything change since the last commit" is the wrong question: commit a | |
| # regeneration by hand and the next run sees a clean tree, reports success and | |
| # silently skips every publish step below, leaving the registry behind forever. | |
| # The tag cannot lie, because whatever is published is what that tag built. | |
| # The spec is the only generator input, so it is the only thing worth diffing; | |
| # a generator version bump changes the output without touching the spec and is | |
| # released deliberately through workflow_dispatch. | |
| - name: Is the published release built from the current spec? | |
| id: diff | |
| run: | | |
| LAST=$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || true) | |
| if [ -z "$LAST" ]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| git show "$LAST:specs/openapi.json" | jq -cS . > "$RUNNER_TEMP/released-spec.json" | |
| jq -cS . specs/openapi.json > "$RUNNER_TEMP/current-spec.json" | |
| if cmp -s "$RUNNER_TEMP/released-spec.json" "$RUNNER_TEMP/current-spec.json"; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Vet, build, test | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| go vet ./... | |
| go build ./... | |
| go test ./... | |
| env: | |
| ROXY_API_KEY: ${{ secrets.ROXY_API_KEY }} | |
| - name: Compute next version | |
| id: bump | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| git fetch --tags --force | |
| LATEST=$(git tag --list 'v*' --sort=-v:refname | head -1) | |
| LATEST=${LATEST:-v0.0.0} | |
| IFS=. read -r MA MI PA <<<"${LATEST#v}" | |
| case "${{ github.event.inputs.version_bump || 'patch' }}" in | |
| major) MA=$((MA+1)); MI=0; PA=0 ;; | |
| minor) MI=$((MI+1)); PA=0 ;; | |
| *) PA=$((PA+1)) ;; | |
| esac | |
| VER="$MA.$MI.$PA" | |
| sed -i "s/const Version = \".*\"/const Version = \"$VER\"/" version.go | |
| echo "version=$VER" >> "$GITHUB_OUTPUT" | |
| - name: Commit, tag, push | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| V=${{ steps.bump.outputs.version }} | |
| git add specs/openapi.json roxyapi.gen.go roxy.gen.go version.go README.md AGENTS.md docs/llms-full.txt | |
| git commit -m "release: v$V" | |
| git tag "v$V" | |
| git push --follow-tags | |
| - name: Index new version on pkg.go.dev | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| env: | |
| GOPROXY: proxy.golang.org | |
| run: go list -m "github.com/RoxyAPI/sdk-go@v${{ steps.bump.outputs.version }}" || true | |
| - name: Create GitHub release | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: v${{ steps.bump.outputs.version }} | |
| generate_release_notes: true | |
| make_latest: 'true' |