Repository navigation
Run a published release by tag, and keep tags off the Latest badge #142
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: | |
| push: | |
| branches: [main] | |
| tags: ["v*"] | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| - { goos: darwin, goarch: arm64, asset: Darwin_arm64 } | |
| - { goos: darwin, goarch: amd64, asset: Darwin_x86_64 } | |
| - { goos: linux, goarch: arm64, asset: Linux_arm64 } | |
| - { goos: linux, goarch: amd64, asset: Linux_x86_64 } | |
| - { goos: windows, goarch: arm64, asset: Windows_arm64 } | |
| - { goos: windows, goarch: amd64, asset: Windows_x86_64 } | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Build | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: "0" | |
| run: | | |
| mkdir -p dist | |
| binary=yolocoder | |
| if [ "$GOOS" = windows ]; then binary=yolocoder.exe; fi | |
| version="${{ github.ref_name }}" | |
| if [ "${{ github.ref_type }}" != tag ]; then version=main; fi | |
| go build -trimpath \ | |
| -ldflags "-s -w -X github.com/mindsdb/yolocoder/internal/version.Version=$version -X github.com/mindsdb/yolocoder/internal/version.Commit=${{ github.sha }}" \ | |
| -o "dist/$binary" ./cmd/yolocoder | |
| - name: Package | |
| run: | | |
| cd dist | |
| if [ "${{ matrix.goos }}" = windows ]; then | |
| zip "yolocoder_${{ matrix.asset }}.zip" yolocoder.exe | |
| rm yolocoder.exe | |
| else | |
| tar -czf "yolocoder_${{ matrix.asset }}.tar.gz" yolocoder | |
| rm yolocoder | |
| fi | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: yolocoder_${{ matrix.asset }} | |
| path: dist/* | |
| retention-days: 1 | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Generate metadata | |
| run: | | |
| cd dist | |
| sha256sum * > checksums.txt | |
| echo "${{ github.sha }}" > commit.txt | |
| - uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_type == 'tag' && github.ref_name || 'latest' }} | |
| name: ${{ github.ref_type == 'tag' && github.ref_name || 'Latest (main)' }} | |
| body: ${{ github.ref_type == 'tag' && '' || format('Continuous build from main at {0}.', github.sha) }} | |
| generate_release_notes: ${{ github.ref_type == 'tag' }} | |
| # The install scripts install GitHub's "Latest" release, and the | |
| # continuous build from main is the one they should get. A tag | |
| # (e.g. a pinned v0.0.0-23f5fce, run with yolocoder --release) | |
| # never takes that badge, and one with a "-" is a pre-release. | |
| prerelease: ${{ github.ref_type == 'tag' && contains(github.ref_name, '-') }} | |
| make_latest: ${{ github.ref_type == 'tag' && 'false' || 'true' }} | |
| files: dist/* |