diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cb54ac4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,44 @@ +name: Release + +on: + pull_request: + branches: [main] + paths: + - .github/workflows/release.yml + - .goreleaser.yaml + push: + tags: ['v*.*.*'] + +jobs: + goreleaser: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache-dependency-path: go.sum + + - uses: goreleaser/goreleaser-action@v6 + if: github.event_name == 'pull_request' + with: + version: '~> v2' + args: release --snapshot + env: + GITHUB_TOKEN: ${{ github.token }} + # Disable the monorepo feature + GORELEASER_CURRENT_TAG: v0.0.1 + GORELEASER_PREVIOUS_TAG: v0.0.1-alpha + + - uses: goreleaser/goreleaser-action@v6 + if: github.event_name != 'pull_request' + with: + version: '~> v2' + args: release --clean + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..e66ff3c --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,49 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj +version: 2 + +before: + hooks: + - make tidy + - make bin/mk_funcs.so + +builds: + - id: devctl + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + +archives: + - formats: [tar.gz] + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + formats: [zip] + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +release: + draft: false + prerelease: auto + extra_files: + - glob: ./bin/mk_funcs.so + name_template: mk_funcs.so