diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0ad05be --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Release + +on: + push: + tags: + - v0.* + + +permissions: + contents: write + +jobs: + release: + name: Build and publish release artifacts + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + cache: true + + - name: Test + run: go test ./... + + - name: Set up GCP credentials + run: echo '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}' > gcp-secret.json + + - name: Run GoReleaser + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + docker run --rm \ + -v "${PWD}:/workspace" \ + -w /workspace \ + -e GITHUB_TOKEN \ + -e GOOGLE_APPLICATION_CREDENTIALS=/workspace/gcp-secret.json \ + ghcr.io/goreleaser/goreleaser-cross:v1.25-v2.12.7 \ + release --clean --parallelism 4 + + - name: Clean up GCP credentials + if: always() + run: rm -f gcp-secret.json diff --git a/.gitignore b/.gitignore index 4c9fca0..7ca624f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ dist TODO* launch.json +apimetrics +gcp-secret.json diff --git a/.goreleaser.yml b/.goreleaser.yml index 21b5759..0f672f9 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -59,6 +59,11 @@ builds: - CC=x86_64-w64-mingw32-gcc - CXX=x86_64-w64-mingw32-g++ +blobs: + - provider: gs + bucket: apimetrics-cli + directory: "{{ .Version }}" + archives: - name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" format_overrides: