name: release on: push: tags: - 'v*' jobs: build: name: Build (${{ matrix.goos }}/${{ matrix.goarch }}) runs-on: ubuntu-latest strategy: matrix: include: - goos: linux goarch: amd64 suffix: -linux-amd64 - goos: windows goarch: amd64 suffix: .exe steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version-file: go.mod - name: Build env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} CGO_ENABLED: "0" run: | go build -trimpath -ldflags="-s -w" \ -o glint-${{ github.ref_name }}${{ matrix.suffix }} \ ./cmd/glint/... - uses: actions/upload-artifact@v4 with: name: binary-${{ matrix.goos }}-${{ matrix.goarch }} path: glint-${{ github.ref_name }}${{ matrix.suffix }} retention-days: 7 release: name: Publish release needs: build runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v4 with: pattern: binary-* merge-multiple: true - name: Create release and upload assets env: TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG: ${{ github.ref_name }} API_URL: ${{ github.api_url }} REPO: ${{ github.repository }} run: | release_id=$(curl -sf -X POST \ -H "Authorization: token $TOKEN" \ -H "Content-Type: application/json" \ "$API_URL/repos/$REPO/releases" \ -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"draft\":false,\"prerelease\":false}" \ | jq -r .id) for file in glint-*; do curl -sf -X POST \ -H "Authorization: token $TOKEN" \ -H "Content-Type: application/octet-stream" \ "$API_URL/repos/$REPO/releases/$release_id/assets?name=$(basename "$file")" \ --data-binary "@$file" echo "uploaded: $file" done