Skip to content

Commit 2ce34d3

Browse files
authored
Create release.yml
1 parent 157fe16 commit 2ce34d3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
push:
3+
tags:
4+
- "v*"
5+
watch:
6+
types: started
7+
8+
name: CI
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: ubuntu-latest
13+
if: github.event.repository.owner.id == github.event.sender.id
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v2
17+
- name: Check git tag exist
18+
run: |
19+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
20+
gitTagExists=$(git tag --points-at HEAD)
21+
if ! [ -n "$gitTagExists" ]; then
22+
echo "no tag, create one."
23+
latesttag=$(git describe --tags `git rev-list --tags --max-count=1`)
24+
echo "latest tag: ${latesttag}"
25+
newtag=$(echo ${latesttag} | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')
26+
echo "new tag: ${newtag}"
27+
git tag $newtag
28+
fi
29+
- name: goreleaser
30+
uses: docker://goreleaser/goreleaser:latest
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
with:
34+
args: release --skip-validate --skip-sign --debug --config .github/goreleaser.yml
35+
if: success()

0 commit comments

Comments
 (0)