Skip to content

Commit

Permalink
ci: switch to goreleaser for publishing release
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Yang <[email protected]>
  • Loading branch information
reaver-flomesh committed Nov 16, 2024
1 parent 1466dfa commit 0a9ac37
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 74 deletions.
77 changes: 3 additions & 74 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,83 +32,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
- 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 release-notes.md

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/
91 changes: 91 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# 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

before:
hooks:
- go mod download

builds:
# fsm build steps
- id: fsm
main: ./cmd/cli
binary: fsm
mod_timestamp: "{{ .CommitTimestamp }}"
env:
- CGO_ENABLED=0
ldflags: &build-ldflags
- -X pkg/version.Version={{ .Env.VERSION }}
- -X pkg/version.GitCommit={{ .Commit }}
- -X pkg/version.BuildDate={{ .Env.BUILD_DATE }}
- -s
- -w
goos:
- darwin
# - windows
- linux
goarch:
- amd64
- arm64
# ignore:
# - goos: windows
# goarch: arm64

archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- .Env.VERSION }}_
{{- .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else }}{{ .Arch }}{{ end }}
files:
- none*
format_overrides:
- goos: windows
format: zip

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 }}!

0 comments on commit 0a9ac37

Please sign in to comment.