Skip to content

Commit

Permalink
ci: switch to goreleaser for publishing release (#445)
Browse files Browse the repository at this point in the history
* ci: switch to goreleaser for publishing release

Signed-off-by: Lin Yang <[email protected]>

* fix: release notes

Signed-off-by: Lin Yang <[email protected]>

* fix: generate-cli-chart

Signed-off-by: Lin Yang <[email protected]>

* fix: goreleaser config

Signed-off-by: Lin Yang <[email protected]>

* feat: add debug

Signed-off-by: Lin Yang <[email protected]>

* refactor: add debug message

Signed-off-by: Lin Yang <[email protected]>

* feat: use goreleaser name template func

Signed-off-by: Lin Yang <[email protected]>

* fix: a typo

Signed-off-by: Lin Yang <[email protected]>

* feat: use goreleaser name template func

Signed-off-by: Lin Yang <[email protected]>

* feat: add zip archives

Signed-off-by: Lin Yang <[email protected]>

* fix: config

Signed-off-by: Lin Yang <[email protected]>

---------

Signed-off-by: Lin Yang <[email protected]>
  • Loading branch information
reaver-flomesh authored Nov 18, 2024
1 parent 1466dfa commit 165aab0
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 76 deletions.
80 changes: 4 additions & 76 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
needs: version
env:
VERSION: ${{ needs.version.outputs.version }}
BUILD_DATE: '$$(date +%Y-%m-%d-%H:%M)'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
Expand All @@ -32,83 +31,12 @@ jobs:
with:
go-version-file: go.mod
cache: true
- name: Build Binaries
run: |
make release-artifacts
- name: Generate Release Notes
run: scripts/release-notes.sh $VERSION > release-notes.md
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
tag: ${{ env.VERSION }}
name: ${{ env.VERSION }}
bodyFile: "release-notes.md"
prerelease: ${{ contains(env.VERSION, '-alpha.') || contains(env.VERSION, '-beta.') || contains(env.VERSION, '-rc.') || contains(env.VERSION, '-nightly.') }}
- name: Upload macOS (amd64).zip
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-darwin-amd64.zip"
asset_name: "fsm-${{ env.VERSION }}-darwin-amd64.zip"
asset_content_type: application/zip
- name: Upload macOS (amd64).tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-darwin-amd64.tar.gz"
asset_name: "fsm-${{ env.VERSION }}-darwin-amd64.tar.gz"
asset_content_type: application/gzip
- name: Upload macOS (arm64).zip
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-darwin-arm64.zip"
asset_name: "fsm-${{ env.VERSION }}-darwin-arm64.zip"
asset_content_type: application/zip
- name: Upload macOS (arm64).tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-darwin-arm64.tar.gz"
asset_name: "fsm-${{ env.VERSION }}-darwin-arm64.tar.gz"
asset_content_type: application/gzip
- name: Upload Linux (amd64).zip
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-linux-amd64.zip"
asset_name: "fsm-${{ env.VERSION }}-linux-amd64.zip"
asset_content_type: application/zip
- name: Upload Linux (amd64).tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-linux-amd64.tar.gz"
asset_name: "fsm-${{ env.VERSION }}-linux-amd64.tar.gz"
asset_content_type: application/gzip
- name: Upload Linux (arm64).zip
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-linux-arm64.zip"
asset_name: "fsm-${{ env.VERSION }}-linux-arm64.zip"
asset_content_type: application/zip
- name: Upload Linux (arm64).tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-linux-arm64.tar.gz"
asset_name: "fsm-${{ env.VERSION }}-linux-arm64.tar.gz"
asset_content_type: application/gzip
- name: Upload Checksums
uses: actions/upload-release-asset@v1
run: scripts/release-notes.sh $VERSION > /tmp/release-notes.md
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: _dist/sha256sums.txt
asset_name: sha256sums.txt
asset_content_type: text/plain
args: release --clean --parallelism 5 --release-notes /tmp/release-notes.md --verbose

images:
name: Docker Images
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ rootfs/

# Interim files that can stick around from a bad mockgen run.
gomock_reflect_*/

dist/
96 changes: 96 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

project_name: fsm

# Global environment variables for builds.
env:
- CGO_ENABLED=0
- GO111MODULE=on

before:
hooks:
- go mod download
- make generate-cli-chart

builds:
# fsm build steps
- id: fsm
main: ./cmd/cli
binary: fsm
mod_timestamp: "{{ .CommitTimestamp }}"
ldflags: &build-ldflags
- -X {{ .GitURL }}/pkg/version.Version={{ .Env.VERSION }}
- -X {{ .GitURL }}/pkg/version.GitCommit={{ .FullCommit }}
- -X {{ .GitURL }}/pkg/version.BuildDate={{ .Now.Format "2006-01-02-15:04" }}
- -s
- -w
goos:
- darwin
- linux
goarch:
- amd64
- arm64


archives:
- id: tar-gz
format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- .Env.VERSION }}_
{{- .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else }}{{ .Arch }}{{ end }}
- id: zip
format: zip
name_template: >-
{{ .ProjectName }}_
{{- .Env.VERSION }}_
{{- .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else }}{{ .Arch }}{{ end }}
checksum:
name_template: "sha256sums.txt"
algorithm: sha256

changelog:
sort: asc
use: github
filters:
exclude:
- '^docs:'
- '^test:'
- '^revert:'
- '^chore:'
- typo
- Merge pull request
- Merge branch
- go mod tidy
groups:
- title: Features
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: 'Bug fixes'
regexp: "^.*fix[(\\w)]*:+.*$"
order: 1
- title: Others
order: 999

release:
prerelease: auto
mode: replace
replace_existing_artifacts: true
header: |
## {{ tolower .ProjectName }} {{ .Tag }}
Welcome to this new release!
footer: |
## Thanks!
Those were the changes on {{ .Tag }}!
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ install-git-pre-push-hook:
# -------------------------------------------
##@ Release Targets

.PHONY: generate-cli-chart
generate-cli-chart: helm-update-dep cmd/cli/chart.tgz

.PHONY: build-cross
build-cross: helm-update-dep cmd/cli/chart.tgz
GO111MODULE=on CGO_ENABLED=0 $(GOX) -ldflags $(LDFLAGS) -parallel=5 -output="_dist/{{.OS}}-{{.Arch}}/$(BINNAME)" -osarch='$(TARGETS)' ./cmd/cli
Expand Down

0 comments on commit 165aab0

Please sign in to comment.