Release workflow updated to use GitHub's release asset upload feature #1
Workflow file for this run
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: | |
| tags: | |
| - 'v*.*.*' # Matches tags like v1.1.1 or v2.0.0 | |
| jobs: | |
| build: | |
| name: Build & Release Binaries | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Required to upload release assets | |
| steps: | |
| - name: ⬇️ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: 🛠️ Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21' | |
| - name: 🧼 Clean previous builds | |
| run: rm -rf dist && mkdir dist | |
| - name: 📦 Build for Linux | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| GOOS=linux GOARCH=amd64 go build -ldflags "-X 'smartcommit/cmd.version=${VERSION}'" -o dist/smartcommit-linux | |
| - name: 📦 Build for macOS | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| GOOS=darwin GOARCH=amd64 go build -ldflags "-X 'smartcommit/cmd.version=${VERSION}'" -o dist/smartcommit-macos | |
| - name: 📦 Build for Windows | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| GOOS=windows GOARCH=amd64 go build -ldflags "-X 'smartcommit/cmd.version=${VERSION}'" -o dist/smartcommit-windows.exe | |
| - name: 📚 Package binaries | |
| run: | | |
| cd dist | |
| tar -czf smartcommit-linux.tar.gz smartcommit-linux | |
| tar -czf smartcommit-macos.tar.gz smartcommit-macos | |
| tar -czf smartcommit-windows.tar.gz smartcommit-windows.exe | |
| - name: 🚀 Create GitHub Release and Upload Assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ github.ref_name }} | |
| tag_name: ${{ github.ref_name }} | |
| files: | | |
| dist/smartcommit-linux.tar.gz | |
| dist/smartcommit-macos.tar.gz | |
| dist/smartcommit-windows.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |