Skip to content

chore: add test build version to draft #71

chore: add test build version to draft

chore: add test build version to draft #71

Workflow file for this run

name: release
on:
push:
branches: [ master, test ]
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
env:
VERSION: ""
COMMIT: ""
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)
commit=$(git rev-parse --short HEAD)
if [ "$new_ver" != "$cur_ver" ]; then
version=$new_ver
else
sed -E "s|v[0-9]+\.[0-9]+\.[0-9]+|test version($commit)|" cmd/compiledb/main.go -i
fi
echo "VERSION=$version" >> $GITHUB_ENV
echo "COMMIT=$commit" >> $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 test --cleanup-tag -y || true
ls -la $out
- uses: actions/upload-artifact@v4
with:
name: binary
path: build/*
- 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: test
artifactErrorsFailBuild: true
generateReleaseNotes: true
name: test version ${{ env.COMMIT }}
prerelease: true
draft: true
artifacts: "build/*"