forked from CanastaWiki/Canasta-CLI
-
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.
Merge pull request CanastaWiki#70 from CanastaWiki/github-actions
Add github actions workflow to build and release
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 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,58 @@ | ||
# This workflow will build and publish a release of Canasta-CLI on pushing to the 'releases' branch. | ||
# It also automatically grabs the current latest version and increments the minor version. | ||
|
||
name: Go build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
- name: Build | ||
run: sh build.sh | ||
- name: Upload executable for job build | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: executable | ||
path: ./Canasta-CLI-Go | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Download executable | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: executable | ||
- name: Rename executable | ||
run: mv Canasta-CLI-Go canasta | ||
- name: Generate Version Tag | ||
id: generate | ||
run: | | ||
latest_version_raw="$(curl -s https://api.github.com/repos/${{ github.repository }}/releases | grep -m 1 "html_url" | rev | cut -d/ -f1 | rev )" | ||
latest_version="${latest_version_raw%??}" | ||
major_version=$(echo $latest_version | cut -d. -f1 | cut -dv -f2) | ||
minor_version=$(echo $latest_version | cut -d. -f2) | ||
patch_version=$(echo $latest_version | cut -d. -f3) | ||
minor_version=$(expr $minor_version + 1) | ||
new_version=$(echo "v$major_version.$minor_version.$patch_version") | ||
echo $new_version | ||
echo "new_version=$new_version" >> $GITHUB_OUTPUT | ||
- name: Publish | ||
uses: softprops/action-gh-release@v1 | ||
id: publish | ||
with: | ||
draft: false | ||
tag_name: ${{ steps.generate.outputs.new_version }} | ||
fail_on_unmatched_files: true | ||
generate_release_notes: true | ||
append_body: true | ||
files: canasta |