[MADE GO MICROSERVICE BOILER PLATE] #23
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*.*.*' # Trigger on version tags like vv1.0.0 | ||
| permissions: | ||
| contents: write | ||
| jobs: | ||
| build-and-release: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| go-version: ["1.20"] | ||
| steps: | ||
| # Checkout repo | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| # Set up Go | ||
| - name: Set up Go ${{ matrix.go-version }} | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ matrix.go-version }} | ||
| # Create release directory | ||
| - name: Create release dir | ||
| run: mkdir -p release | ||
| # Build Linux binary | ||
| - name: Build Linux | ||
| run: GOOS=linux GOARCH=amd64 go build -o release/gores-linux-amd64 main.go | ||
| # Build macOS binary | ||
| - name: Build macOS | ||
| run: GOOS=darwin GOARCH=amd64 go build -o release/gores-darwin-amd64 main.go | ||
| # Build Windows binary | ||
| - name: Build Windows | ||
| run: GOOS=windows GOARCH=amd64 go build -o release/gores-windows-amd64.exe main.go | ||
| # Create GitHub Release | ||
| - name: Create Release | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: ${{ github.ref_name }} | ||
| files: | | ||
| release/gores-linux-amd64 | ||
| release/gores-darwin-amd64 | ||
| release/gores-windows-amd64.exe | ||
| - name: Upload Linux binary | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: gores-linux-amd64 | ||
| path: release/gores-linux-amd64 | ||
| - name: Upload macOS binary | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: gores-darwin-amd64 | ||
| path: release/gores-darwin-amd64 | ||
| - name: Upload Windows binary | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: gores-windows-amd64.exe | ||
| path: release/gores-windows-amd64.exe | ||
| release: | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| needs: build-and-release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Download Linux artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: ubuntu-latest-binary | ||
| path: release | ||
| - name: Download macOS artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: macos-latest-binary | ||
| path: release | ||
| - name: Download Windows artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: windows-latest-binary | ||
| path: release | ||
| - name: Create GitHub Release | ||
| id: create_release | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: ${{ github.ref_name }} | ||
| name: 🚀 Go Microservice Boilerplate ${{ github.ref_name }} | ||
| body: | | ||
| ## 📦 Go Microservice Boilerplate — ${{ github.ref_name }} | ||
| Precompiled binaries are available for **Linux**, **macOS**, and **Windows**. | ||
| ### 🔽 1. Download Binaries | ||
| - **Linux (x86_64)** → [gores-linux-amd64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-linux-amd64) | ||
| - **macOS (x86_64)** → [gores-darwin-amd64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-darwin-amd64) | ||
| - **Windows (x86_64)** → [gores-windows-amd64.exe](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-windows-amd64.exe) | ||
| #### Linux / macOS | ||
| ```bash | ||
| curl -L -o gores https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-linux-amd64 | ||
| chmod +x gores | ||
| ./gores | ||
| ``` | ||
| #### Windows (PowerShell) | ||
| ```powershell | ||
| Invoke-WebRequest -Uri "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gores-windows-amd64.exe" -OutFile "gores.exe" | ||
| .\gores.exe | ||
| ``` | ||
| --- | ||
| ### 💻 2. Install via `go install` (Go 1.17+) | ||
| ```bash | ||
| go install github.com/${{ github.repository }}@${{ github.ref_name }} | ||
| ``` | ||
| This will install the binary into your `$GOPATH/bin` or `$HOME/go/bin`. | ||
| --- | ||
| ### 📥 3. Install via `go get` (older Go versions) | ||
| ```bash | ||
| go get github.com/${{ github.repository }}@${{ github.ref_name }} | ||
| ``` | ||
| --- | ||
| ### 🛠 4. Build from Source | ||
| ```bash | ||
| git clone https://github.com/${{ github.repository }}.git | ||
| cd $(basename $_ .git) | ||
| go mod tidy | ||
| go build -o gores ./cmd | ||
| ``` | ||
| --- | ||
| ### 📚 Documentation | ||
| For full docs and usage examples, see [README.md](https://github.com/${{ github.repository }}#readme) | ||
| --- | ||
| _Built automatically via GitHub Actions._ | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.MY_PAT }} | ||
| - name: Upload Linux binary | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: ${{ github.ref_name }} | ||
| asset_path: release/gores | ||
| asset_name: gores-linux-amd64 | ||
| asset_content_type: application/octet-stream | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.MY_PAT }} | ||
| - name: Upload macOS binary | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: ${{ github.ref_name }} | ||
| asset_path: release/gores | ||
| asset_name: gores-darwin-amd64 | ||
| asset_content_type: application/octet-stream | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.MY_PAT }} | ||
| - name: Upload Windows binary | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: ${{ github.ref_name }} | ||
| asset_path: release/gores.exe | ||
| asset_name: gores-windows-amd64.exe | ||
| asset_content_type: application/octet-stream | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.MY_PAT }} | ||