name: Build on: push: branches: - main tags: - 'v*.*.*' permissions: contents: read jobs: build: runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v5 with: go-version: '1.26' cache: true - name: Build binary run: | set -euo pipefail version=$(tr -d '[:space:]' < VERSION) echo "Building chat-bot $version" go build \ -trimpath \ -ldflags "-s -w -X main.version=$version" \ -o bin/chat-bot \ ./cmd/chat-bot - name: Sanity check run: ./bin/chat-bot version - name: Upload artifact uses: actions/upload-artifact@v4 with: name: chat-bot-${{ github.sha }} path: bin/chat-bot retention-days: 14 - name: Attach to release if: startsWith(github.ref, 'refs/tags/') env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | if gh release view "${{ github.ref_name }}" >/dev/null 2>&1; then gh release upload "${{ github.ref_name }}" bin/chat-bot --clobber echo "Attached bin/chat-bot to ${{ github.ref_name }}" else echo "No release for ${{ github.ref_name }} (tag has [skip-release] or release not created yet), skipping attachment" fi