Create CloudEndpoint.txt #4
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
# 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 | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # 拉取所有历史记录 | |
- name: Create Zip Archive | |
run: | | |
zip -r release.zip * | |
- name: Fetch all tags | |
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Get latest tag | |
id: latest-tag | |
run: | | |
# 获取最新的 tag | |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) | |
echo "Latest tag: $LATEST_TAG" | |
echo ::set-output name=tag::${LATEST_TAG} | |
- name: Increment tag | |
id: increment-tag | |
run: | | |
# 解析 tag 并递增 | |
LATEST_TAG=${{ steps.latest-tag.outputs.tag }} | |
BASE_TAG=$(echo "$LATEST_TAG" | sed 's/\(.*\)\.\([0-9]*\)$/\1/') | |
VERSION=$(echo "$LATEST_TAG" | sed 's/.*\.\([0-9]*\)$/\1/') | |
NEW_VERSION=$((VERSION + 1)) | |
NEW_TAG="$BASE_TAG.$NEW_VERSION" | |
echo ::set-output name=new-tag::${NEW_TAG} | |
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV | |
- name: Create and Upload Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# 创建 Release | |
gh release create $NEW_TAG --title "Release $NEW_TAG" --notes "github action自动构建" | |
# 上传当前目录下所有 zip 文件为 Release 附件 | |
for zip_file in *.zip; do | |
gh release upload $NEW_TAG "$zip_file" --clobber | |
done |