From 4499b48e963bbc56fc6ef97a62d14425cec24982 Mon Sep 17 00:00:00 2001 From: budougumi0617 Date: Wed, 18 Sep 2024 06:47:18 +0900 Subject: [PATCH 1/3] ci: upgrade goreleaser and use tagpr --- .github/workflows/goreleaser.yml | 46 +++++++++++----- .goreleaser.yml | 93 +++++++++++++++++--------------- CHANGELOG.md | 0 3 files changed, 82 insertions(+), 57 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 455044e..eadf651 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -5,25 +5,45 @@ on: tags: - "v[0-9]+.[0-9]+.[0-9]+" jobs: + tagpr: + runs-on: ubuntu-latest + outputs: + tagpr-tag: ${{ steps.run-tagpr.outputs.tag }} + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + steps: + - name: Check out source code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + - id: run-tagpr + name: Run tagpr + uses: Songmu/tagpr@v1 goreleaser: + needs: tagpr + if: needs.tagpr.outputs.tagpr-tag != '' runs-on: ubuntu-latest steps: - - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v4 with: fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 + - name: Set up Go + uses: actions/setup-go@v5 with: - go-version: 1.15 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + go-version-file: go.mod + cache: true + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 with: - version: latest - args: release --rm-dist + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + # 'latest', 'nightly', or a semver + version: "latest" + args: release --clean env: # need to access other repository for brew-tap - GITHUB_TOKEN: ${{ secrets.GH_PAT }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GH_PAT }} diff --git a/.goreleaser.yml b/.goreleaser.yml index ca2f6e9..64f568f 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,68 +1,73 @@ +version: 2 + before: hooks: - # you may remove this if you don't use vgo + - go mod download - go mod tidy - # you may remove this if you don't need go generate - #- go generate ./... + builds: - - - main: ./cmd/nrseg + - id: nrseg-darwin ldflags: - -s -w -X main.Version={{.Version}} -X main.Revision={{.ShortCommit}} env: - CGO_ENABLED=0 + goos: + - darwin + goarch: + - amd64 + - arm64 + main: ./cmd/nrseg/main.go + - id: nrseg-linux + env: + - CGO_ENABLED=0 + goos: + - linux + goarch: + - amd64 + - arm64 + main: ./cmd/nrseg/main.go + - id: nrseg-windows + env: + - CGO_ENABLED=0 + goos: + - windows + goarch: + - amd64 + main: ./cmd/nrseg/main.go + archives: - - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 + - format: 'tar.gz' + name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}' + files: + - CHANGELOG.md + - LICENSE.txt + - README.md checksum: - name_template: 'checksums.txt' + name_template: "checksums.txt" snapshot: name_template: "{{ .Tag }}-next" + changelog: sort: asc filters: exclude: - - '^docs:' - - '^test:' -brews: - - - # Name template of the recipe - # Default to project name - name: nrseg + - "^docs:" + - "^test:" - # Github repository to push the tap to. - tap: +brews: + - name: nrseg + url_template: "https://github.com/budougumi0617/nrseg/releases/download/{{ .Tag }}/{{ .ArtifactName }}" + repository: owner: budougumi0617 name: homebrew-tap - - # Template for the url which is determined by the given Token (github or gitlab) - # Default for github is "https://github.com///releases/download/{{ .Tag }}/{{ .ArtifactName }}" - # Default for gitlab is "https://gitlab.com///uploads/{{ .ArtifactUploadHash }}/{{ .ArtifactName }}" - url_template: "https://github.com/budougumi0617/nrseg/releases/download/{{ .Tag }}/{{ .ArtifactName }}" - - # Git author used to commit to the repository. - # Defaults are shown. + token: "{{ .Env.GITHUB_TOKEN }}" commit_author: - name: budougumi0617 - email: budougumi0617@gmail.com - - # Your app's homepage. - # Default is empty. + name: "github-actions[bot]" + email: "github-actions[bot]@users.noreply.github.com" homepage: "https://github.com/budougumi0617/nrseg" - - # Your app's description. - # Default is empty. description: "Insert function segments into any function/method for Newrelic APM." - - # So you can `brew test` your formula. - # Default is empty. + license: "MIT" + install: | + bin.install "nrseg" test: | system "#{bin}/nrseg -h" - # Custom install script for brew. - # Default is 'bin.install "program"'. - install: | - bin.install "nrseg" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 From 2fe5151e4f46072eba713f480bb2dbac403532f3 Mon Sep 17 00:00:00 2001 From: budougumi0617 Date: Wed, 18 Sep 2024 06:48:46 +0900 Subject: [PATCH 2/3] chore: rename --- .github/workflows/{goreleaser.yml => tag-and-release.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{goreleaser.yml => tag-and-release.yml} (98%) diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/tag-and-release.yml similarity index 98% rename from .github/workflows/goreleaser.yml rename to .github/workflows/tag-and-release.yml index eadf651..d5de058 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/tag-and-release.yml @@ -1,4 +1,4 @@ -name: goreleaser +name: tag-and-release on: push: From ebabd0402d077a7e2b9c7bc486f69f2950da9ac9 Mon Sep 17 00:00:00 2001 From: budougumi0617 Date: Wed, 18 Sep 2024 06:55:00 +0900 Subject: [PATCH 3/3] fix(ci): fix trigger --- .github/workflows/tag-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tag-and-release.yml b/.github/workflows/tag-and-release.yml index d5de058..58c8d22 100644 --- a/.github/workflows/tag-and-release.yml +++ b/.github/workflows/tag-and-release.yml @@ -2,8 +2,8 @@ name: tag-and-release on: push: - tags: - - "v[0-9]+.[0-9]+.[0-9]+" + branches: + - master jobs: tagpr: runs-on: ubuntu-latest