-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: makefile * refactor: update logger * chore: update workflwo * feat: better logger * fix: remove version as we are using gh cli * chore: makes pre-release builds on dev now * chore: fix workflow not getting proper version * chore: fix workflow not having gh_token * chore: fix release not working properly * fix: remove useless fi
- Loading branch information
Showing
7 changed files
with
131 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
- master | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.23 | ||
|
||
- name: Get the current version | ||
id: get_version | ||
run: | | ||
VERSION=$(gh release list --limit 1 | head -n 1 | awk '{print $2}') | ||
echo "Current version is $VERSION" | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
|
||
- name: Calculate new version | ||
id: new_version | ||
run: | | ||
VERSION=${{ env.VERSION }} | ||
IFS='.' read -r major minor patch <<<"$VERSION" | ||
if [ "${{ github.ref }}" == "refs/heads/dev" ]; then | ||
patch=$((patch+1)) | ||
elif [ "${{ github.ref }}" == "refs/heads/master" ]; then | ||
minor=$((minor+1)) | ||
patch=0 | ||
fi | ||
NEW_VERSION="$major.$minor.$patch" | ||
echo "New version is $NEW_VERSION" | ||
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | ||
- name: Build binaries for Linux | ||
run: GOARCH=amd64 GOOS=linux go build -o ./target/${{ github.event.repository.name }}-linux main.go | ||
|
||
- name: Build binaries for Windows | ||
run: GOARCH=amd64 GOOS=windows go build -o ./target/${{ github.event.repository.name }}-windows main.go | ||
|
||
- name: Build binaries for MacOS | ||
run: GOARCH=amd64 GOOS=darwin go build -o ./target/${{ github.event.repository.name }}-darwin main.go | ||
|
||
- name: Create release | ||
run: | | ||
if [ "${{ github.ref }}" == "refs/heads/dev" ]; then | ||
gh release create ${{ env.NEW_VERSION }} ./target/${{ github.event.repository.name }}-linux ./target/${{ github.event.repository.name }}-windows ./target/${{ github.event.repository.name }}-darwin --title "Release ${{ env.NEW_VERSION }}" --notes "Release generated by GitHub Actions" --prerelease | ||
elif [ "${{ github.ref }}" == "refs/heads/master" ]; then | ||
gh release create ${{ env.NEW_VERSION }} ./target/${{ github.event.repository.name }}-linux ./target/${{ github.event.repository.name }}-windows ./target/${{ github.event.repository.name }}-darwin --title "Release ${{ env.NEW_VERSION }}" --notes "Release generated by GitHub Actions" | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"cSpell.words": ["lockb", "packagejson", "softprops", "Typeflag"] | ||
"cSpell.words": ["GOARCH", "lockb", "packagejson", "softprops", "Typeflag"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
BIN_NAME=yap | ||
.DEFAULT_GOAL := run | ||
|
||
build: | ||
GOARCH=amd64 GOOS=darwin go build -o ./target/${BIN_NAME}-darwin main.go | ||
GOARCH=amd64 GOOS=windows go build -o ./target/${BIN_NAME}-windows main.go | ||
GOARCH=amd64 GOOS=linux go build -o ./target/${BIN_NAME}-linux main.go | ||
|
||
run: build | ||
./target/${BIN_NAME}-linux | ||
|
||
build_and_run: build run | ||
|
||
clean: | ||
go clean | ||
rimraf ./target | ||
|
||
test: | ||
go test ./... | ||
|
||
test_coverage: | ||
go test ./... -coverprofile=coverage.out | ||
|
||
dep: | ||
go mod downlaoad | ||
|
||
vet: | ||
go vet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters