File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Create Release
2+
3+ on :
4+ push :
5+ branches : [master]
6+
7+ permissions :
8+ contents : write
9+
10+ jobs :
11+ create_release :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - uses : actions/checkout@v6
15+ with :
16+ fetch-depth : 0
17+
18+ - name : Get version from build.gradle
19+ id : version
20+ run : |
21+ VERSION=$(grep "^version = " build.gradle | sed "s/version = '\(.*\)'/\1/")
22+ echo "version=$VERSION" >> $GITHUB_OUTPUT
23+
24+ - name : Check if tag exists
25+ id : check
26+ run : |
27+ VERSION="${{ steps.version.outputs.version }}"
28+ if git rev-parse "v${VERSION}" >/dev/null 2>&1; then
29+ echo "Tag v${VERSION} already exists, skipping release"
30+ echo "should_release=false" >> $GITHUB_OUTPUT
31+ else
32+ echo "Tag v${VERSION} does not exist, will create release"
33+ echo "should_release=true" >> $GITHUB_OUTPUT
34+ fi
35+
36+ - name : Create tag and release
37+ if : steps.check.outputs.should_release == 'true'
38+ run : |
39+ git config user.name "github-actions[bot]"
40+ git config user.email "github-actions[bot]@users.noreply.github.com"
41+ git tag v${{ steps.version.outputs.version }}
42+ git push origin v${{ steps.version.outputs.version }}
43+ gh release create v${{ steps.version.outputs.version }} --generate-notes
44+ env :
45+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments