initial commit #1
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: | |
| branches: | |
| - main | |
| - master | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| goos: [linux, windows, darwin] | |
| goarch: [amd64, arm64] | |
| # Ignore unsupported combinations if any, but these are generally fine. | |
| exclude: | |
| - goos: windows | |
| goarch: arm64 | |
| 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" -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 |