Skip to content

Update v0.1.9

Update v0.1.9 #122

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go build
env:
ProductName: gtbox
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
outputs:
UPLOAD_URL: ${{ steps.stepCreateRelease.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get latest tag
run: |
echo "LATEST_TAG=$(git tag | grep -v '^latest$' | sort -V | tail -n1)" >> $GITHUB_ENV
- name: Bump version and push tag
id: tag-version
uses: mathieudutour/github-tag-action@v6.1
with:
tag_prefix: ""
custom_tag: ${{ env.LATEST_TAG }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Step GitHub release
id: stepCreateRelease
uses: ncipollo/release-action@v1
with:
skipIfReleaseExists: 'true'
tag: ${{ env.LATEST_TAG }}
name: ${{ env.LATEST_TAG }}
Build:
runs-on: ubuntu-latest
needs: release
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
steps:
- name: CheckOut
uses: actions/checkout@v4
- name: Set APP_VERSION env
run: echo APP_VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev ) >> ${GITHUB_ENV}
- name: Set BUILD_TIME env
run: echo BUILD_TIME=$(date) >> ${GITHUB_ENV}
- name: Environment Printer
uses: managedkaos/print-env@v1.0
- name: GO Release
uses: wangyoucao577/go-release-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
build_flags: -v
overwrite: true
ldflags: -X "${{ env.ProductName }}.appVersion=${{ env.APP_VERSION }}" -X "${{ env.ProductName }}.buildTime=${{ env.BUILD_TIME }}" -X ${{ env.ProductName }}.gitCommit=${{ github.sha }} -X ${{ env.ProductName }}.gitRef=${{ github.ref }}
RemoveOldRelease:
runs-on: ubuntu-latest
needs: Build
steps:
- name: install github-cli
run: |
type -p curl >/dev/null || sudo apt install curl -y
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: CheckOut
uses: actions/checkout@v4
- name: Set APP_VERSION env
run: |
APP_VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev ) \
&& echo APP_OLD_VERSION=${APP_VERSION%.*}.$((${APP_VERSION##*.}-2)) >> ${GITHUB_ENV}
- name: Remove Old Release
run: |
gh release delete ${{ env.APP_OLD_VERSION }} -y
git push origin --delete ${{ env.APP_OLD_VERSION }}
env:
GH_TOKEN: ${{ github.token }}