From e16f5773036b29361cbbbee2cdd1300ea6bb52fc Mon Sep 17 00:00:00 2001 From: deggja Date: Fri, 4 Oct 2024 20:08:02 +0200 Subject: [PATCH] ci: refactor release process using goreleaser Signed-off-by: deggja --- .github/scripts/bump_version.sh | 41 --------------------------------- .github/workflows/release.yml | 28 ++++------------------ .goreleaser.yml | 3 +++ 3 files changed, 8 insertions(+), 64 deletions(-) delete mode 100755 .github/scripts/bump_version.sh diff --git a/.github/scripts/bump_version.sh b/.github/scripts/bump_version.sh deleted file mode 100755 index 94eba60..0000000 --- a/.github/scripts/bump_version.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -# Fetch tags -git fetch --tags -latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null) - -# Initialize variables -major=0 -minor=0 -patch=0 - -if [ ! -z "$latest_tag" ]; then - # Parse the current version - IFS='.' read -r major minor patch <<< "${latest_tag}" -fi - -# Analyze commit messages since the last tag for versioning -for commit in $(git rev-list $latest_tag..HEAD); do - message=$(git log --format=%B -n 1 $commit) - - if [[ $message == *"#major"* ]]; then - let major+=1 - minor=0 - patch=0 - break - elif [[ $message == *"#minor"* ]]; then - let minor+=1 - patch=0 - elif [[ $message == *"#patch"* ]]; then - let patch+=1 - fi -done - -new_tag="${major}.${minor}.${patch}" - -# Set output for the next steps using environment file -echo "new_tag=$new_tag" >> $GITHUB_ENV - -# Create the new tag -git tag $new_tag -git push --tags \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b8c72e1..997ead1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,21 +1,9 @@ name: Release on: - workflow_dispatch: - inputs: - logLevel: - description: 'Log level' - required: true - default: 'info' - environment: - description: 'Environment' - required: false push: - branches: - - main - paths: - - 'backend/**' - - 'frontend/**' + tags: + - 'v*.*.*' jobs: build-and-release: @@ -23,12 +11,12 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go 1.21 - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: go-version: '1.21' @@ -37,14 +25,8 @@ jobs: cd backend go mod tidy - - name: Bump version and tag - id: bump_version - run: | - chmod +x .github/scripts/bump_version.sh - .github/scripts/bump_version.sh - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v6 with: version: latest args: release --clean diff --git a/.goreleaser.yml b/.goreleaser.yml index 5e9be80..d26815c 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -49,6 +49,9 @@ archives: format: tar.gz name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" wrap_in_directory: true +before: + hooks: + - go mod tidy # Release Configuration release: