Skip to content

Commit

Permalink
Refactor release step
Browse files Browse the repository at this point in the history
  • Loading branch information
Andriiklymiuk committed May 30, 2023
1 parent 5c36e8c commit ea72aa1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 60 deletions.
41 changes: 36 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: goreleaser
name: Create release

on:
push:
tags:
- "*"
workflow_dispatch:
branches:
- "main"

jobs:
goreleaser:
Expand All @@ -14,11 +13,43 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.20.3

- name: Get version and add it to GITHUB_ENV
run: make getActionVersion

- name: Extract APP_VERSION and Create Tag
id: create-tag
run: |
TAG="v${VERSION}"
echo "VERSION: ${VERSION}"
echo "TAG: $TAG"
# Check if the tag exists
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${GITHUB_TOKEN}" https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/$TAG)
if [ "$HTTP_STATUS" -ne 200 ]
then
echo "Tag does not exist, creating new tag"
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git tag $TAG
git push origin $TAG
echo "TAG_EXISTS=false" >> $GITHUB_ENV
else
echo "Tag already exists"
echo "TAG_EXISTS=true" >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

- name: Run GoReleaser
if: env.TAG_EXISTS == 'false'
uses: goreleaser/goreleaser-action@v3
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
Expand Down
54 changes: 0 additions & 54 deletions .github/workflows/tag.yml

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
)

var APP_VERSION = "1.1.62"
var APP_VERSION = "1.1.63"

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Expand Down

0 comments on commit ea72aa1

Please sign in to comment.