feat: return make errorCode #75
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: "" | |
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 | |
echo "Build linux-amd64 version" | |
GOOS=linux GOARCH=amd64 go build | |
chmod +x compiledb | |
./compiledb -h | head -1 || true | |
tar cJvf compiledb.txz compiledb | |
mv compiledb.txz $out/compiledb-linux-amd64.txz | |
echo "Build linux-arm64 version" | |
GOOS=linux GOARCH=arm64 go build | |
chmod +x compiledb | |
tar cJvf compiledb.txz compiledb | |
mv compiledb.txz $out/compiledb-linux-arm64.txz | |
echo "Build windows-amd64 version" | |
GOOS=windows GOARCH=amd64 go build | |
7z a compiledb.7z compiledb.exe | |
mv compiledb.7z $out/compiledb-windows-amd64.7z | |
echo "Build darwin-arm64 version" | |
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: compiledb-linux-amd64 | |
path: build/compiledb-linux-amd64.txz | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: compiledb-windows-amd64 | |
path: build/compiledb-windows-amd64.7z | |
- 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/*" |