11name : Release Extension
22
33on :
4- workflow_dispatch : # Allows manual triggering
5- pull_request : # Run on pull requests
6- # push:
7- # branches:
8- # - main # Triggers on pushes to the main branch
4+ push :
5+ branches : [main] # Automatic releases on main branch
6+ workflow_dispatch : # Manual triggering
97
108permissions :
119 contents : write
10+ issues : write
11+ pull-requests : write
1212
1313jobs :
14- build :
14+ release :
1515 runs-on : ubuntu-latest
1616 steps :
1717 - name : Checkout code
1818 uses : actions/checkout@v4
19+ with :
20+ fetch-depth : 0 # Fetch full history for semantic-release
21+ token : ${{ secrets.GITHUB_TOKEN }}
1922
2023 - name : Set up JDK 21
2124 uses : actions/setup-java@v4
@@ -26,57 +29,47 @@ jobs:
2629 - name : Set up Gradle
2730 uses : gradle/actions/setup-gradle@v4
2831
29- - name : Build extension
30- run : ./gradlew bwextension
31-
32- - name : Upload extension artifact
33- uses : actions/upload-artifact@v4
34- with :
35- name : WigAI.bwextension
36- path : build/extensions/WigAI.bwextension
37-
38- release :
39- runs-on : ubuntu-latest
40- needs : build
41- if : github.event_name == 'workflow_dispatch'
42- # || (github.event_name == 'push' && github.ref == 'refs/heads/main')
43- steps :
44- - name : Checkout code
45- uses : actions/checkout@v4
46- with :
47- fetch-depth : 0 # Fetch all history for changelog generation
48-
49- - name : Download extension artifact
50- uses : actions/download-artifact@v4
51- with :
52- name : WigAI.bwextension
53- path : . # Download directly into the current workspace directory
54-
55- - name : Set up Node.js
32+ - name : Setup Node.js
5633 uses : actions/setup-node@v4
5734 with :
5835 node-version : ' lts/*'
5936
60- - name : Install conventional-changelog-cli
61- run : npm install -g conventional-changelog-cli conventional-commits-parser
37+ - name : Install semantic-release
38+ run : |
39+ npm install -g semantic-release
40+ npm install -g @semantic-release/changelog
41+ npm install -g @semantic-release/git
42+ npm install -g @semantic-release/github
43+ npm install -g @semantic-release/exec
44+
45+ - name : Run tests
46+ run : ./gradlew test
6247
63- - name : Generate release notes
64- run : conventional-changelog -p angular -i CHANGELOG.md -s -r 0 > RELEASE_NOTES.md && cat RELEASE_NOTES.md
48+ - name : Run semantic-release
49+ run : semantic-release
50+ env :
51+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6552
66- - name : Get project version
67- id : get_version
68- run : echo "PROJECT_VERSION=$( ./gradlew -q printVersion)" >> $GITHUB_ENV
53+ - name : Build extension (if version was bumped)
54+ if : env.SEMANTIC_RELEASE_NEW_RELEASE_PUBLISHED == 'true'
55+ run : ./gradlew bwextension
6956
70- - name : Generate tag name
71- id : generate_tag # id is not strictly needed here as we are using GITHUB_ENV but good practice
72- run : echo "TAG_NAME=release-${{ env.PROJECT_VERSION }}-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
57+ - name : Get release info for asset upload
58+ if : env.SEMANTIC_RELEASE_NEW_RELEASE_PUBLISHED == 'true'
59+ id : release_info
60+ run : |
61+ RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
62+ "https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ env.SEMANTIC_RELEASE_VERSION }}" \
63+ | jq -r '.id')
64+ echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
7365
74- - name : Create GitHub Release
75- uses : softprops/action-gh-release@v1
76- with :
77- tag_name : ${{ env.TAG_NAME }}
78- name : Release ${{ env.TAG_NAME }}
79- body_path : RELEASE_NOTES.md
80- files : WigAI.bwextension # Updated path
66+ - name : Upload extension to release
67+ if : env.SEMANTIC_RELEASE_NEW_RELEASE_PUBLISHED == 'true'
68+ uses : actions/upload-release-asset@v1
8169 env :
8270 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
71+ with :
72+ upload_url : https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.release_id }}/assets{?name,label}
73+ asset_path : build/extensions/WigAI.bwextension
74+ asset_name : WigAI.bwextension
75+ asset_content_type : application/java-archive
0 commit comments