Skip to content

patch: give clear message after init; auto-reload when apt in use #65

patch: give clear message after init; auto-reload when apt in use

patch: give clear message after init; auto-reload when apt in use #65

Workflow file for this run

name: Build and release
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
goarch: [amd64, arm64]
goos: [linux, darwin]
outputs:
bump_tag: ${{ steps.set_output.outputs.bump_tag }}
old_pre_tag: ${{ steps.set_output.outputs.old_pre_tag }}
if: contains(github.event.head_commit.message, 'patch:') || contains(github.event.head_commit.message, 'feat:') || contains(github.event.head_commit.message, 'feat(bump):')
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:')
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:')
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:')
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:')
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):')
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):')
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:')
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 and zip binary file
if: env.BUMP_TAG != 'NULL'
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags "-X odoo-one-click/config.VERSION=${{ env.BUMP_TAG }}" -o odoo-one-click .
zip odoo-one-click_${{ matrix.goos }}_${{ matrix.goarch }}.zip odoo-one-click
rm -f odoo-one-click
mkdir -p publish
mv *.zip ./publish/
- name: Set output
id: set_output
if: env.BUMP_TAG != 'NULL'
run: |
echo "bump_tag=${{ env.BUMP_TAG }}" >> $GITHUB_OUTPUT
echo "old_pre_tag=${{ env.OLD_PRE_TAG }}" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@master
if: env.BUMP_TAG != 'NULL'
with:
name: publish-binaries
path: ${{ github.workspace }}/publish
deploy:
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.bump_tag && needs.build.outputs.old_pre_tag
steps:
- name: Delete old prerelease tag with v0.x.x
if: (needs.build.outputs.old_pre_tag == needs.build.outputs.bump_tag) && (needs.build.outputs.bump_tag != 'NULL')
uses: dev-drprasad/[email protected]
with:
delete_release: true
tag_name: ${{ needs.build.outputs.old_pre_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Restore artifacts
uses: actions/download-artifact@master
if: needs.build.outputs.bump_tag != 'NULL'
with:
name: publish-binaries
path: ${{ github.workspace }}/publish
- name: Conventional Changelog Action
id: changelog
uses: TriPSs/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
output-file: "false"
- name: Publish GitHub Release
if: needs.build.outputs.bump_tag != 'NULL'
uses: ncipollo/[email protected]
with:
prerelease: env.PRERELEASE
artifacts: "${{ github.workspace }}/publish/*.zip"
tag: "${{ needs.build.outputs.bump_tag }}"
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ steps.changelog.outputs.clean_changelog }}