chore: add latest prerelease version #57
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: release | |
on: | |
push: | |
branches: [ master, test ] | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
VERSION: "" | |
GH_TOKEN: ${{ github.token }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: 'stable' | |
- run: go version | |
- name: Check need release | |
id: check_release | |
run: | | |
version="" | |
new_ver=$(grep -Po "v\d+\.\d+\.\d+" cmd/compiledb/main.go) | |
cur_ver=$(git describe --abbrev=0 --tags) | |
if [ "$new_ver" != "$cur_ver" ]; then | |
version=$new_ver | |
else | |
id=$(git rev-parse --short HEAD) | |
sed -E "s|v[0-9]+\.[0-9]+\.[0-9]+|$id|" cmd/compiledb/main.go -i | |
fi | |
echo "VERSION=$version" >> $GITHUB_ENV | |
- name: Install dependencies | |
run: go mod tidy | |
- name: Build | |
run: | | |
out=$(pwd)/build | |
mkdir -p $out | |
cd ./cmd/compiledb | |
GOOS=linux GOARCH=amd64 go build | |
chmod +x compiledb | |
tar cJvf compiledb.txz compiledb | |
mv compiledb.txz $out/compiledb-linux-amd64.txz | |
GOOS=linux GOARCH=arm64 go build | |
chmod +x compiledb | |
tar cJvf compiledb.txz compiledb | |
mv compiledb.txz $out/compiledb-linux-arm64.txz | |
GOOS=windows GOARCH=amd64 go build | |
7z a compiledb.7z compiledb.exe | |
mv compiledb.7z $out/compiledb-windows-amd64.7z | |
GOOS=darwin GOARCH=arm64 go build | |
chmod +x compiledb | |
tar cJvf compiledb.txz compiledb | |
mv compiledb.txz $out/compiledb-darwin-arm64.txz | |
gh release delete latest -y || true | |
git push origin :latest || true | |
ls -la $out | |
- name: Release | |
if: ${{ env.VERSION != '' }} | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ env.VERSION }} | |
allowUpdates: true | |
artifactErrorsFailBuild: true | |
generateReleaseNotes: true | |
artifacts: "build/*" | |
- name: Update latest | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: latest | |
artifactErrorsFailBuild: true | |
generateReleaseNotes: true | |
prerelease: true | |
artifacts: "build/*" |