From 2b336549ada18e2c2d9a6be4e1cf7ac4caee6663 Mon Sep 17 00:00:00 2001 From: Nolan Jacobson <50815660+nolanjacobson@users.noreply.github.com> Date: Fri, 16 Aug 2024 16:35:06 -0400 Subject: [PATCH] chore: Go releaser workflow (#491) * chore: add goreleaser workflows Signed-off-by: mudler * chore: add test workflow Signed-off-by: mudler * fix: use github-native for release notes generation See also: https://goreleaser.com/customization/changelog/?h=changelog#changelog Signed-off-by: mudler --------- Signed-off-by: mudler Co-authored-by: mudler Co-authored-by: Brendan Playford <34052452+teslashibe@users.noreply.github.com> --- .github/workflows/build-goreleaser-test.yml | 25 ++++++++++++++ .github/workflows/goreleaser.yml | 30 ++++++++++++++++ .gitignore | 3 ++ .goreleaser.yml | 38 +++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 .github/workflows/build-goreleaser-test.yml create mode 100644 .github/workflows/goreleaser.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/build-goreleaser-test.yml b/.github/workflows/build-goreleaser-test.yml new file mode 100644 index 00000000..761f013d --- /dev/null +++ b/.github/workflows/build-goreleaser-test.yml @@ -0,0 +1,25 @@ +name: goreleaser-build-test + +on: + push: + pull_request: + +jobs: + goreleaser: # Add this new job for GoReleaser + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.22 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: v2.1.0 + args: build --clean --snapshot + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 00000000..dccaa4f8 --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,30 @@ +name: goreleaser + +on: + push: + tags: + - 'v*' # Add this line to trigger the workflow on tag pushes that match 'v*' + +permissions: + id-token: write + contents: read + +jobs: + goreleaser: # Add this new job for GoReleaser + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.22 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: v2.1.0 + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 3fc6bb2b..eaa12583 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,6 @@ docs/api-reference.md transcription.txt snippets.txt .env copy + +# Build result of goreleaser +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..230d00e2 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,38 @@ +# Make sure to check the documentation at http://goreleaser.com +version: 2 +builds: + - main: ./cmd/masa-node/main.go + ldflags: + - -w -s + - -X github.com/masa-finance/masa-oracle/internal.Version={{.Tag}} + - -X github.com/masa-finance/masa-oracle/internal.Commit={{.Commit}} + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + - freebsd + goarch: + - amd64 + - arm + - arm64 +source: + enabled: true + name_template: '{{ .ProjectName }}-{{ .Tag }}-source' +archives: + # Default template uses underscores instead of - + - name_template: >- + {{ .ProjectName }}-{{ .Tag }}- + {{- if eq .Os "freebsd" }}FreeBSD + {{- else }}{{- title .Os }}{{end}}- + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{end}} + {{- if .Arm }}v{{ .Arm }}{{ end }} +checksum: + name_template: '{{ .ProjectName }}-{{ .Tag }}-checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + use: github-native \ No newline at end of file