Skip to content

Commit 2580f68

Browse files
authored
Create blank.yml
1 parent aa68aa6 commit 2580f68

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/blank.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
# This workflow will build a golang project
3+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
4+
5+
name: Go
6+
7+
on:
8+
push:
9+
branches: [ "main" ]
10+
pull_request:
11+
branches: [ "main" ]
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-20.04
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
20+
- name: Checkout code
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0 # 拉取所有历史记录
24+
25+
- name: Create Zip Archive
26+
run: |
27+
zip -r release.zip *
28+
29+
- name: Fetch all tags
30+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
31+
32+
- name: Get latest tag
33+
id: latest-tag
34+
run: |
35+
# 获取最新的 tag
36+
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
37+
echo "Latest tag: $LATEST_TAG"
38+
echo ::set-output name=tag::${LATEST_TAG}
39+
- name: Increment tag
40+
id: increment-tag
41+
run: |
42+
# 解析 tag 并递增
43+
LATEST_TAG=${{ steps.latest-tag.outputs.tag }}
44+
BASE_TAG=$(echo "$LATEST_TAG" | sed 's/\(.*\)\.\([0-9]*\)$/\1/')
45+
VERSION=$(echo "$LATEST_TAG" | sed 's/.*\.\([0-9]*\)$/\1/')
46+
NEW_VERSION=$((VERSION + 1))
47+
NEW_TAG="$BASE_TAG.$NEW_VERSION"
48+
echo ::set-output name=new-tag::${NEW_TAG}
49+
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
50+
- name: Create and Upload Release
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
run: |
54+
# 创建 Release
55+
gh release create $NEW_TAG --title "Release $NEW_TAG" --notes "github action自动构建"
56+
57+
# 上传当前目录下所有 zip 文件为 Release 附件
58+
for zip_file in *.zip; do
59+
gh release upload $NEW_TAG "$zip_file" --clobber
60+
done

0 commit comments

Comments
 (0)