diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..50032f8 --- /dev/null +++ b/.github/workflows/release.yml @@ -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