patch: add auto-install script #39
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
name: Build and release | |
on: | |
push: | |
branches: [ "main" ] | |
# TODO: need to create unit test, and run the test when do PR to branches main | |
# pull_request: | |
# branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Manage Version | |
run: | | |
git fetch --prune --unshallow --tags | |
CUR_TAG="$(git tag -l | tail -1)" | |
echo "BUMP_TAG=NULL" >> $GITHUB_ENV | |
if [[ -z $CUR_TAG ]]; then | |
echo "CUR_TAG=0.1.0" >> $GITHUB_ENV | |
echo "OLD_PRE_TAG=NULL" >> $GITHUB_ENV | |
else | |
echo "CUR_TAG=$CUR_TAG" >> $GITHUB_ENV | |
echo "OLD_PRE_TAG=$CUR_TAG" >> $GITHUB_ENV | |
fi | |
- name: Increment patch version | |
id: bump_patch | |
if: contains(github.event.head_commit.message, 'patch:') == true | |
uses: christian-draeger/[email protected] | |
with: | |
current-version: ${{ env.CUR_TAG }} | |
version-fragment: 'bug' | |
- name: Set env patch | |
if: contains(github.event.head_commit.message, 'patch:') == true | |
run: | | |
echo "BUMP_TAG=${{ steps.bump_patch.outputs.next-version }}" >> $GITHUB_ENV | |
echo "PRERELEASE=${{ true }}" >> $GITHUB_ENV | |
- name: Increment minor version | |
id: bump_minor | |
if: contains(github.event.head_commit.message, 'feat:') == true | |
uses: christian-draeger/[email protected] | |
with: | |
current-version: ${{ env.CUR_TAG }} | |
version-fragment: 'feature' | |
- name: Set env minor | |
if: contains(github.event.head_commit.message, 'feat:') == true | |
run: | | |
echo "BUMP_TAG=${{ steps.bump_minor.outputs.next-version }}" >> $GITHUB_ENV | |
echo "PRERELEASE=${{ true }}" >> $GITHUB_ENV | |
- name: Increment major version | |
id: bump_major | |
if: contains(github.event.head_commit.message, 'feat(bump):') == true | |
uses: christian-draeger/[email protected] | |
with: | |
current-version: ${{ env.CUR_TAG }} | |
version-fragment: 'major' | |
- name: Set env major | |
if: contains(github.event.head_commit.message, 'feat(bump):') == true | |
run: | | |
echo "BUMP_TAG=${{ steps.bump_major.outputs.next-version }}" >> $GITHUB_ENV | |
echo "PRERELEASE=${{ true }}" >> $GITHUB_ENV | |
- name: Set RELEASE tag | |
if: contains(github.event.head_commit.message, ':release:') == true | |
run: | | |
echo "PRERELEASE=${{ false }}" >> $GITHUB_ENV | |
- name: Set up Go | |
if: env.BUMP_TAG != 'NULL' | |
uses: actions/setup-go@v3 | |
with: | |
cache: true | |
go-version: 1.19 | |
- name: Get dependencies and format | |
if: env.BUMP_TAG != 'NULL' | |
run: | | |
go mod tidy | |
go fmt ./... | |
- name: Build amd64 | |
if: env.BUMP_TAG != 'NULL' | |
run: | | |
GOOS=linux GOARCH=amd64 go build -ldflags "-X odoo-one-click/config.VERSION=${{ env.BUMP_TAG }}" -o odoo-one-click . | |
zip odoo-one-click_amd64_config.VERSION=${{ env.BUMP_TAG }}.zip odoo-one-click | |
rm -f odoo-one-click | |
# - name: Build arm64 | |
# if: env.BUMP_TAG != 'NULL' | |
# run: | | |
# GOOS=linux GOARCH=arm64 go build -ldflags "-X odoo-one-click/config.VERSION=${{ env.BUMP_TAG }}" -o odoo-one-click . | |
# zip odoo-one-click_arm64.zip odoo-one-click | |
# rm -f odoo-one-click | |
- name: Delete old prerelease tag with v0.x.x | |
if: (env.OLD_PRE_TAG == env.BUMP_TAG) && (env.BUMP_TAG != 'NULL') | |
uses: dev-drprasad/[email protected] | |
with: | |
delete_release: true | |
tag_name: ${{ env.OLD_PRE_TAG }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish GitHub Release | |
if: env.BUMP_TAG != 'NULL' | |
uses: ncipollo/[email protected] | |
with: | |
prerelease: env.PRERELEASE | |
artifacts: "*.zip" | |
tag: "${{ env.BUMP_TAG }}" | |
token: ${{ secrets.GITHUB_TOKEN }} |