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