refactor(version): move version variable to a dedicated util package #6
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: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| goos: [linux, windows, darwin] | |
| goarch: [amd64, arm64, arm] | |
| exclude: | |
| - goos: windows | |
| goarch: arm64 | |
| - goos: windows | |
| goarch: arm | |
| - goos: darwin | |
| goarch: arm | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' # Update this to your project's Go version if needed | |
| cache: true | |
| - name: Fetch Dependencies | |
| run: go mod download | |
| - name: Build | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| run: | | |
| mkdir -p build | |
| EXT="" | |
| if [ "${{ matrix.goos }}" = "windows" ]; then | |
| EXT=".exe" | |
| fi | |
| go build -ldflags "-s -w -X main.version=${{ github.ref_name }}" -o build/telbot-${{ matrix.goos }}-${{ matrix.goarch }}$EXT . | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: telbot-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: build/telbot-* | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| # Only run this job if a tag was pushed (e.g. v1.0.0) | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: artifacts/**/* | |
| draft: false | |
| prerelease: false |