From de438f14ad77a4b731828eff7a97730fbafce1ee Mon Sep 17 00:00:00 2001 From: Sung Yoon Whang Date: Thu, 20 Jul 2023 22:58:38 -0700 Subject: [PATCH] setup releaser GH action (#43) --- .github/workflows/release.yaml | 61 ++++++++++++++++++++++++++++++++++ .goreleaser.yml | 3 +- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..ea76e73 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,61 @@ +name: release + +on: + push: + tags: ['v*'] + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: 1.20.x + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Load cached dependencies + uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Prepare release + run: | + set -eou pipefail + make bin/extract-changelog + + # Extract target version number from the git tag and post it to + # GITHUB_ENV to make it accessible via env.VERSION in other steps. + VERSION=${{ github.ref }} + VERSION="${VERSION#refs/tags/}" # refs/tags/v1.2.3 => v1.2.3 + echo "VERSION=$VERSION" >> $GITHUB_ENV + + echo "Releasing $VERSION" + + # Place the release notes in changes.v1.2.3.txt to grab them in the + # release step. + echo "Release notes:" + echo "----" + bin/extract-changelog $VERSION | tee changes.$VERSION.txt + echo "----" + + - name: Release + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --clean --release-notes changes.${{ env.VERSION }}.txt + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GORELEASER_CURRENT_TAG: ${{ env.VERSION }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 7fc27c0..683abe2 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -4,7 +4,7 @@ --- release: github: - owner: golang + owner: uber name: mock builds: @@ -33,6 +33,7 @@ archives: checksum: snapshot: name_template: "snap-{{ .Commit }}" + changelog: sort: asc filters: