chore: update workflows
81450e22
2 file(s) · +158 −0
| 1 | + | name: Release |
|
| 2 | + | ||
| 3 | + | # Tag scheme: <app>/vX.Y.Z (e.g. sipp/v0.1.0) |
|
| 4 | + | # The app dir must contain its own .goreleaser.yml. |
|
| 5 | + | on: |
|
| 6 | + | push: |
|
| 7 | + | tags: |
|
| 8 | + | - "*/v*" |
|
| 9 | + | ||
| 10 | + | permissions: |
|
| 11 | + | contents: write |
|
| 12 | + | ||
| 13 | + | jobs: |
|
| 14 | + | goreleaser: |
|
| 15 | + | name: Release ${{ github.ref_name }} |
|
| 16 | + | runs-on: ubuntu-latest |
|
| 17 | + | steps: |
|
| 18 | + | - name: Parse app name from tag |
|
| 19 | + | id: parse |
|
| 20 | + | run: | |
|
| 21 | + | tag="${GITHUB_REF_NAME}" |
|
| 22 | + | app="${tag%%/*}" |
|
| 23 | + | version="${tag#*/}" |
|
| 24 | + | echo "app=$app" >> "$GITHUB_OUTPUT" |
|
| 25 | + | echo "version=$version" >> "$GITHUB_OUTPUT" |
|
| 26 | + | echo "Releasing $app $version" |
|
| 27 | + | ||
| 28 | + | - uses: actions/checkout@v6 |
|
| 29 | + | with: |
|
| 30 | + | fetch-depth: 0 |
|
| 31 | + | ||
| 32 | + | - name: Find previous tag for this app |
|
| 33 | + | id: prev |
|
| 34 | + | run: | |
|
| 35 | + | app="${{ steps.parse.outputs.app }}" |
|
| 36 | + | current="${GITHUB_REF_NAME}" |
|
| 37 | + | prev=$(git tag --list "${app}/v*" --sort=-v:refname | grep -v "^${current}$" | head -n1 || true) |
|
| 38 | + | if [ -n "$prev" ]; then |
|
| 39 | + | prev_ver="${prev#*/}" |
|
| 40 | + | echo "tag=$prev_ver" >> "$GITHUB_OUTPUT" |
|
| 41 | + | echo "Previous release: $prev_ver" |
|
| 42 | + | else |
|
| 43 | + | echo "tag=" >> "$GITHUB_OUTPUT" |
|
| 44 | + | echo "No previous release for $app" |
|
| 45 | + | fi |
|
| 46 | + | ||
| 47 | + | - name: Verify app has goreleaser config |
|
| 48 | + | run: | |
|
| 49 | + | cfg="apps/${{ steps.parse.outputs.app }}/.goreleaser.yml" |
|
| 50 | + | if [ ! -f "$cfg" ]; then |
|
| 51 | + | echo "::error::No $cfg — app not configured for releases." |
|
| 52 | + | exit 1 |
|
| 53 | + | fi |
|
| 54 | + | ||
| 55 | + | - uses: actions/setup-go@v6 |
|
| 56 | + | with: |
|
| 57 | + | go-version: '1.25.x' |
|
| 58 | + | cache-dependency-path: | |
|
| 59 | + | apps/*/go.sum |
|
| 60 | + | pkg/*/go.sum |
|
| 61 | + | ||
| 62 | + | - name: Resolve replace directives |
|
| 63 | + | # GoReleaser archives need self-contained sources; replace dirs |
|
| 64 | + | # are fine for `go build` but tags must point at real versions |
|
| 65 | + | # or we keep local replaces working by running in-tree (which we do). |
|
| 66 | + | working-directory: apps/${{ steps.parse.outputs.app }} |
|
| 67 | + | run: go mod tidy |
|
| 68 | + | ||
| 69 | + | - uses: goreleaser/goreleaser-action@v6 |
|
| 70 | + | with: |
|
| 71 | + | distribution: goreleaser |
|
| 72 | + | version: "~> v2" |
|
| 73 | + | args: release --clean --skip=publish,announce |
|
| 74 | + | workdir: apps/${{ steps.parse.outputs.app }} |
|
| 75 | + | env: |
|
| 76 | + | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
| 77 | + | # Strip "app/" prefix so goreleaser parses as semver. |
|
| 78 | + | GORELEASER_CURRENT_TAG: ${{ steps.parse.outputs.version }} |
|
| 79 | + | GORELEASER_PREVIOUS_TAG: ${{ steps.prev.outputs.tag }} |
|
| 80 | + | ||
| 81 | + | - name: Create GitHub release and upload artifacts |
|
| 82 | + | working-directory: apps/${{ steps.parse.outputs.app }} |
|
| 83 | + | env: |
|
| 84 | + | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
| 85 | + | run: | |
|
| 86 | + | app="${{ steps.parse.outputs.app }}" |
|
| 87 | + | version="${{ steps.parse.outputs.version }}" |
|
| 88 | + | tag="${GITHUB_REF_NAME}" |
|
| 89 | + | assets=$(find dist -maxdepth 1 -type f \( -name '*.tar.gz' -o -name '*.zip' -o -name 'checksums.txt' \)) |
|
| 90 | + | gh release create "$tag" \ |
|
| 91 | + | --title "$app $version" \ |
|
| 92 | + | --generate-notes \ |
|
| 93 | + | $assets |
| 1 | + | # GoReleaser config for sipp. |
|
| 2 | + | # Triggered by tags shaped like `sipp/vX.Y.Z`. |
|
| 3 | + | version: 2 |
|
| 4 | + | ||
| 5 | + | project_name: sipp |
|
| 6 | + | ||
| 7 | + | before: |
|
| 8 | + | hooks: |
|
| 9 | + | - go mod tidy |
|
| 10 | + | ||
| 11 | + | builds: |
|
| 12 | + | - id: sipp |
|
| 13 | + | main: . |
|
| 14 | + | binary: sipp |
|
| 15 | + | env: |
|
| 16 | + | - CGO_ENABLED=0 |
|
| 17 | + | goos: |
|
| 18 | + | - linux |
|
| 19 | + | - darwin |
|
| 20 | + | - windows |
|
| 21 | + | goarch: |
|
| 22 | + | - amd64 |
|
| 23 | + | - arm64 |
|
| 24 | + | ignore: |
|
| 25 | + | - goos: windows |
|
| 26 | + | goarch: arm64 |
|
| 27 | + | ldflags: |
|
| 28 | + | - -s -w |
|
| 29 | + | - -X main.version={{.Version}} |
|
| 30 | + | - -X main.commit={{.Commit}} |
|
| 31 | + | - -X main.date={{.Date}} |
|
| 32 | + | ||
| 33 | + | archives: |
|
| 34 | + | - id: sipp |
|
| 35 | + | name_template: >- |
|
| 36 | + | {{ .ProjectName }}_{{ .Version }}_ |
|
| 37 | + | {{- if eq .Os "darwin" }}macos{{- else }}{{ .Os }}{{ end }}_ |
|
| 38 | + | {{- if eq .Arch "amd64" }}x86_64{{- else }}{{ .Arch }}{{ end }} |
|
| 39 | + | formats: [tar.gz] |
|
| 40 | + | format_overrides: |
|
| 41 | + | - goos: windows |
|
| 42 | + | formats: [zip] |
|
| 43 | + | files: |
|
| 44 | + | - README.md |
|
| 45 | + | ||
| 46 | + | checksum: |
|
| 47 | + | name_template: "checksums.txt" |
|
| 48 | + | ||
| 49 | + | snapshot: |
|
| 50 | + | version_template: "0.0.0-snapshot-{{.ShortCommit}}" |
|
| 51 | + | ||
| 52 | + | changelog: |
|
| 53 | + | use: github |
|
| 54 | + | sort: asc |
|
| 55 | + | filters: |
|
| 56 | + | exclude: |
|
| 57 | + | - "^docs:" |
|
| 58 | + | - "^test:" |
|
| 59 | + | - "^chore:" |
|
| 60 | + | ||
| 61 | + | release: |
|
| 62 | + | # Disabled: workflow uploads artifacts to the real `sipp/vX.Y.Z` git tag |
|
| 63 | + | # using `gh release create`. GoReleaser OSS can't natively map a stripped |
|
| 64 | + | # version back to a prefixed tag without the Pro `monorepo` feature. |
|
| 65 | + | disable: true |