From 4c9492765803c12b83f07164056dd251a3a0b3bc Mon Sep 17 00:00:00 2001 From: Benson Wong Date: Sat, 14 Dec 2024 10:16:46 -0800 Subject: [PATCH] Move release to Makefile out of goreleaser - less complexity - easier - goreleaser, github, pipelines: 1... mostlygeek: 0 --- .github/workflows/release.yml | 23 +++++++---------------- Makefile | 11 +++++++++++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b55a25..570d6c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,8 +2,8 @@ name: goreleaser on: push: - branches: - - main + tags: + - '*' permissions: contents: write @@ -20,23 +20,14 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 - - - name: Get commit count - id: get_commit_count - run: echo "COMMIT_COUNT=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT - - - name: Create release tag - run: | - git config user.name github-actions - git config user.email github-actions@github.com - git tag -a v${{ steps.get_commit_count.outputs.COMMIT_COUNT }} -m "Release v${{ steps.get_commit_count.outputs.COMMIT_COUNT }}" - git push origin v${{ steps.get_commit_count.outputs.COMMIT_COUNT }} - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: + # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser - version: latest - args: release --clean --snapshot + # 'latest', 'nightly', or a semver + version: '~> v2' + args: release --clean env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Makefile b/Makefile index f3c5216..7930ad3 100644 --- a/Makefile +++ b/Makefile @@ -45,5 +45,16 @@ simple-responder: $(BUILD_DIR): mkdir -p $(BUILD_DIR) +# Create a new release tag +release: + @echo "Checking for unstaged changes..." + @if [ -n "$(shell git status --porcelain)" ]; then \ + echo "Error: There are unstaged changes. Please commit or stash your changes before creating a release tag." >&2; \ + exit 1; \ + fi + @echo "Creating release tag v$(COMMIT_COUNT)..." + git tag v$(COMMIT_COUNT) + git push origin v$(COMMIT_COUNT) + # Phony targets .PHONY: all clean osx linux