diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index dc0d1ef6..b0cbc438 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,13 +2,58 @@ name: Release on: push: - branches: - - main + tags: + - 'v*' + +permissions: + contents: write jobs: - release-please: + goreleaser: + runs-on: ubuntu-latest + environment: production + steps: + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Fetch all tags + run: git fetch --force --tags + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Get ldflags env values + run: | + echo "BUILD_TIMESTAMP=$(date +'%s')" >> $GITHUB_ENV + echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + echo "COMMIT_HASH=${{ github.sha }}" >> $GITHUB_ENV + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v3 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + version: runs-on: ubuntu-latest + environment: production steps: - - uses: google-github-actions/release-please-action@v3 - with: - release-type: go + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: main + - name: Bump version + run: | + echo ${{ github.ref_name }} > VERSION + - name: Commit version to repository + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "chore(release): bump version to ${{ github.ref_name }}" diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..aee22400 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,50 @@ +before: + hooks: + - go mod tidy +builds: +- env: + - CGO_ENABLED=0 + - PACKAGE=github.com/padok-team/burrito + ldflags: + - -X ${PACKAGE}/internal/version.Version=${VERSION} + - -X ${PACKAGE}/internal/version.CommitHash=${COMMIT_HASH} + - -X ${PACKAGE}/internal/version.BuildTimestamp=${BUILD_TIMESTAMP} + goos: + - linux + - darwin + main: ./ + binary: burrito +archives: +- replacements: + darwin: Darwin + linux: Linux + 386: i386 + amd64: x86_64 + format_overrides: + - goos: windows + format: zip +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: '{{ .Tag }}-next' +changelog: + sort: asc + use: github + groups: + - title: Features + regexp: "^.*(feat:|feat\\/|feat(\\([^\\)]*\\)):).*" + order: 0 + - title: 'Bug fixes' + regexp: "^.*(fix:|fix\\/|fix(\\([^\\)]*\\)):).*" + order: 1 + - title: Others + order: 999 + filters: + exclude: + - '^docs' + - '^test' + - '^style' + - '^refactor' + - '^build' + - '^ci' + - '^chore(release)' diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..38f8e886 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +dev