feat #42
Workflow file for this run
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: | |
tags: | |
- 'v*' | |
permissions: | |
contents: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Create Code Release | |
runs-on: ubuntu-latest | |
env: | |
GOPATH: ${{ github.workspace }}/go | |
GOBIN: ${{ github.workspace }}/go/bin | |
defaults: | |
run: | |
working-directory: ${{ github.workspace }} | |
steps: | |
- name: Setup Compile Timezone | |
run: | | |
echo "TZ=Asia/Shanghai" >> $GITHUB_ENV | |
- name: Get Compile Timezone | |
run: | | |
date | |
- name: Checkout Project Code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
path: ${{ github.workspace }} | |
- name: Build Golang Environment | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.22' | |
cache: true | |
- name: View Golang Environment | |
run: | | |
go version | |
go env | |
- name: Generate Golang Ldflags | |
id: genLdflags | |
run: | | |
CODEREPO="github.com/${{ github.repository }}" | |
COMMIT="-X \"${CODEREPO}/version.Version=`git describe --always --no-match --tags --dirty="-dev"`\"" | |
BUILDTS="-X \"${CODEREPO}/version.BuildTS=`TZ=CST-8 date '+%Y-%m-%d %H:%M:%S'`\"" | |
GITHASH="-X \"${CODEREPO}/version.GitHash=`git rev-parse HEAD`\"" | |
GITREF="-X \"${CODEREPO}/version.GitBranch=`git rev-parse --abbrev-ref HEAD`\"" | |
LDFLAGS="-w -s ${COMMIT} ${BUILDTS} ${GITHASH} ${GITREF}" | |
echo "ldflags=${LDFLAGS}" >> $GITHUB_ENV | |
- name: Install Cross Platform Environment | |
run: | | |
go install src.techknowlogick.com/xgo@latest | |
- name: Cross Platform Compile Linux amd64 | |
run: | | |
cd ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-master -targets=linux/amd64 -pkg component/master ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-worker -targets=linux/amd64 -pkg component/worker ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-cluster -targets=linux/amd64 -pkg component/cluster ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-ctl -targets=linux/amd64 -pkg component/cli ${{ github.workspace }} | |
ls -lnrt ${{ github.workspace }}/bin | |
sudo mv ${{ github.workspace }}/bin/dbms-master-linux-amd64 ${{ github.workspace }}/bin/dbms-master | |
sudo mv ${{ github.workspace }}/bin/dbms-worker-linux-amd64 ${{ github.workspace }}/bin/dbms-worker | |
sudo mv ${{ github.workspace }}/bin/dbms-cluster-linux-amd64 ${{ github.workspace }}/bin/dbms-cluster | |
sudo mv ${{ github.workspace }}/bin/dbms-ctl-linux-amd64 ${{ github.workspace }}/bin/dbms-ctl | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64 | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64/example | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64/instantclient | |
sudo chmod -R 777 ${{ github.workspace }}/build | |
cd ${{ github.workspace }}/bin | |
pwd | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64/dbms-master-${{ github.ref_name }}-linux-amd64.tar.gz dbms-master | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64/dbms-worker-${{ github.ref_name }}-linux-amd64.tar.gz dbms-worker | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64/dbms-cluster-${{ github.ref_name }}-linux-amd64.tar.gz dbms-cluster | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64/dbms-ctl-${{ github.ref_name }}-linux-amd64.tar.gz dbms-ctl | |
sudo cp -r ${{ github.workspace }}/example/* ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64/example/ | |
sudo cp -r ${{ github.workspace }}/local_install.sh ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64/ | |
sudo cp -r ${{ github.workspace }}/instantclient/instantclient-v19.23.0-linux-amd64.tar.gz ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64/instantclient/ | |
sudo chmod +x ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64/local_install.sh | |
cd ${{ github.workspace }}/build | |
pwd | |
sudo tar -zcvf dbms-community-${{ github.ref_name }}-linux-amd64.tar.gz dbms-community-${{ github.ref_name }}-linux-amd64/ | |
ls -lnrt ${{ github.workspace }}/build | |
ls -lnrt ${{ github.workspace }}/bin | |
sudo rm -rf ${{ github.workspace }}/bin/* | |
ls -lnrt ${{ github.workspace }}/bin | |
- name: Cross Platform Compile Linux arm64 | |
run: | | |
cd ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-master -targets=linux/arm64 -pkg component/master ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-worker -targets=linux/arm64 -pkg component/worker ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-cluster -targets=linux/arm64 -pkg component/cluster ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-ctl -targets=linux/arm64 -pkg component/cli ${{ github.workspace }} | |
ls -lnrt ${{ github.workspace }}/bin | |
sudo mv ${{ github.workspace }}/bin/dbms-master-linux-arm64 ${{ github.workspace }}/bin/dbms-master | |
sudo mv ${{ github.workspace }}/bin/dbms-worker-linux-arm64 ${{ github.workspace }}/bin/dbms-worker | |
sudo mv ${{ github.workspace }}/bin/dbms-cluster-linux-arm64 ${{ github.workspace }}/bin/dbms-cluster | |
sudo mv ${{ github.workspace }}/bin/dbms-ctl-linux-arm64 ${{ github.workspace }}/bin/dbms-ctl | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64 | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64/example | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64/instantclient | |
sudo chmod -R 777 ${{ github.workspace }}/build | |
cd ${{ github.workspace }}/bin | |
pwd | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64/dbms-master-${{ github.ref_name }}-linux-arm64.tar.gz dbms-master | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64/dbms-worker-${{ github.ref_name }}-linux-arm64.tar.gz dbms-worker | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64/dbms-cluster-${{ github.ref_name }}-linux-arm64.tar.gz dbms-cluster | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64/dbms-ctl-${{ github.ref_name }}-linux-arm64.tar.gz dbms-ctl | |
sudo cp -r ${{ github.workspace }}/example/* ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64/example/ | |
sudo cp -r ${{ github.workspace }}/local_install.sh ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64/ | |
sudo cp -r ${{ github.workspace }}/instantclient/instantclient-v19.23.0-linux-arm64.tar.gz ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64/instantclient/ | |
sudo chmod +x ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64/local_install.sh | |
cd ${{ github.workspace }}/build | |
pwd | |
sudo tar -zcvf dbms-community-${{ github.ref_name }}-linux-arm64.tar.gz dbms-community-${{ github.ref_name }}-linux-arm64/ | |
ls -lnrt ${{ github.workspace }}/build | |
ls -lnrt ${{ github.workspace }}/bin | |
sudo rm -rf ${{ github.workspace }}/bin/* | |
ls -lnrt ${{ github.workspace }}/bin | |
- name: Cross Platform Compile Darwin amd64 | |
run: | | |
cd ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-master -targets=darwin/amd64 -pkg component/master ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-worker -targets=darwin/amd64 -pkg component/worker ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-cluster -targets=darwin/amd64 -pkg component/cluster ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-ctl -targets=darwin/amd64 -pkg component/cli ${{ github.workspace }} | |
ls -lnrt ${{ github.workspace }}/bin | |
sudo mv ${{ github.workspace }}/bin/dbms-master-darwin-10.12-amd64 ${{ github.workspace }}/bin/dbms-master | |
sudo mv ${{ github.workspace }}/bin/dbms-worker-darwin-10.12-amd64 ${{ github.workspace }}/bin/dbms-worker | |
sudo mv ${{ github.workspace }}/bin/dbms-cluster-darwin-10.12-amd64 ${{ github.workspace }}/bin/dbms-cluster | |
sudo mv ${{ github.workspace }}/bin/dbms-ctl-darwin-10.12-amd64 ${{ github.workspace }}/bin/dbms-ctl | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64 | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64/example | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64/instantclient | |
sudo chmod -R 777 ${{ github.workspace }}/build | |
cd ${{ github.workspace }}/bin | |
pwd | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64/dbms-master-${{ github.ref_name }}-darwin-amd64.tar.gz dbms-master | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64/dbms-worker-${{ github.ref_name }}-darwin-amd64.tar.gz dbms-worker | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64/dbms-cluster-${{ github.ref_name }}-darwin-amd64.tar.gz dbms-cluster | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64/dbms-ctl-${{ github.ref_name }}-darwin-amd64.tar.gz dbms-ctl | |
sudo cp -r ${{ github.workspace }}/example/* ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64/example/ | |
sudo cp -r ${{ github.workspace }}/local_install.sh ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64/ | |
sudo cp -r ${{ github.workspace }}/instantclient/instantclient-v19.8.0-darwin-amd64.tar.gz ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64/instantclient/ | |
sudo chmod +x ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64/local_install.sh | |
cd ${{ github.workspace }}/build | |
pwd | |
sudo tar -zcvf dbms-community-${{ github.ref_name }}-darwin-amd64.tar.gz dbms-community-${{ github.ref_name }}-darwin-amd64/ | |
ls -lnrt ${{ github.workspace }}/build | |
ls -lnrt ${{ github.workspace }}/bin | |
sudo rm -rf ${{ github.workspace }}/bin/* | |
ls -lnrt ${{ github.workspace }}/bin | |
- name: Cross Platform Compile Darwin arm64 | |
run: | | |
cd ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-master -targets=darwin/arm64 -pkg component/master ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-worker -targets=darwin/arm64 -pkg component/worker ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-cluster -targets=darwin/arm64 -pkg component/cluster ${{ github.workspace }} | |
xgo -ldflags='${{ env.ldflags }}' -buildmode=default -dest bin -go go-1.22.x -out=dbms-ctl -targets=darwin/arm64 -pkg component/cli ${{ github.workspace }} | |
ls -lnrt ${{ github.workspace }}/bin | |
sudo mv ${{ github.workspace }}/bin/dbms-master-darwin-10.12-arm64 ${{ github.workspace }}/bin/dbms-master | |
sudo mv ${{ github.workspace }}/bin/dbms-worker-darwin-10.12-arm64 ${{ github.workspace }}/bin/dbms-worker | |
sudo mv ${{ github.workspace }}/bin/dbms-cluster-darwin-10.12-arm64 ${{ github.workspace }}/bin/dbms-cluster | |
sudo mv ${{ github.workspace }}/bin/dbms-ctl-darwin-10.12-arm64 ${{ github.workspace }}/bin/dbms-ctl | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64 | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64/example | |
sudo mkdir -p ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64/instantclient | |
sudo chmod -R 777 ${{ github.workspace }}/build | |
cd ${{ github.workspace }}/bin | |
pwd | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64/dbms-master-${{ github.ref_name }}-darwin-arm64.tar.gz dbms-master | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64/dbms-worker-${{ github.ref_name }}-darwin-arm64.tar.gz dbms-worker | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64/dbms-cluster-${{ github.ref_name }}-darwin-arm64.tar.gz dbms-cluster | |
sudo tar -zcvf ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64/dbms-ctl-${{ github.ref_name }}-darwin-arm64.tar.gz dbms-ctl | |
sudo cp -r ${{ github.workspace }}/example/* ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64/example/ | |
sudo cp -r ${{ github.workspace }}/local_install.sh ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64/ | |
sudo cp -r ${{ github.workspace }}/instantclient/instantclient-v19.8.0-darwin-arm64.tar.gz ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64/instantclient/ | |
sudo chmod +x ${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64/local_install.sh | |
cd ${{ github.workspace }}/build | |
pwd | |
sudo tar -zcvf dbms-community-${{ github.ref_name }}-darwin-arm64.tar.gz dbms-community-${{ github.ref_name }}-darwin-arm64/ | |
ls -lnrt ${{ github.workspace }}/build | |
ls -lnrt ${{ github.workspace }}/bin | |
sudo rm -rf ${{ github.workspace }}/bin/* | |
ls -lnrt ${{ github.workspace }}/bin | |
- name: Build Release Changelog | |
id: github_release | |
uses: mikepenz/release-changelog-builder-action@v4 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
configurationJson: | | |
{ | |
"template": "#{{CHANGELOG}}\n\n<details>\n<summary>Uncategorized</summary>\n\n#{{UNCATEGORIZED}}\n</details>", | |
"categories": [ | |
{ | |
"title": "## 🚀 Features", | |
"labels": ["feature","feat"] | |
}, | |
{ | |
"title": "## 🐛 Fixes", | |
"labels": ["fix","fixed"] | |
}, | |
{ | |
"title": "## 🧪 Tests", | |
"labels": ["test"] | |
}, | |
{ | |
"title": "## 📦 Docs", | |
"labels": ["docs","doc"] | |
}, | |
{ | |
"title": "## 💬 chore", | |
"labels": [] | |
} | |
], | |
"label_extractor": [ | |
{ | |
"pattern": "^(chore|doc|docs|feat|fix|fixed|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)", | |
"target": "$1" | |
} | |
] | |
} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Platform Asserts | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
name: ${{ github.ref_name }} | |
tag_name: ${{ github.ref }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: ${{steps.github_release.outputs.changelog}} | |
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-b') || contains(github.ref, '-a') }} | |
files: | | |
${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-amd64.tar.gz | |
${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-linux-arm64.tar.gz | |
${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-amd64.tar.gz | |
${{ github.workspace }}/build/dbms-community-${{ github.ref_name }}-darwin-arm64.tar.gz |