1+ # GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps:
2+ # - Remove Old Draft Releases
3+ # - Create New Draft Release
4+ # The workflow is triggered on push to the main branch
5+ #
6+ # GitHub Actions reference: https://help.github.com/en/actions
7+ #
8+ on :
9+ push :
10+ branches :
11+ - main
12+
13+ jobs :
14+ publish_snapshot :
15+ name : Publish Snapshot
16+ runs-on : ubuntu-latest
17+ steps :
18+ # Check out current repository
19+ - name : Fetch Sources
20+ uses : actions/checkout@v3
21+
22+ # Set up Java environment for the next steps
23+ - name : Setup Java
24+ uses : actions/setup-java@v3
25+ with :
26+ distribution : zulu
27+ java-version : 17
28+ - name : Publish Snapshot
29+ run : |
30+ chmod +x ./publish_snapshot.sh
31+ ./publish_snapshot.sh ${{secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME}} ${{secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD}}
32+
33+ update_draft_release :
34+ name : Create or Update Draft Release
35+ runs-on : ubuntu-latest
36+ steps :
37+ # Check out current repository
38+ - name : Fetch Sources
39+ uses : actions/checkout@v3
40+
41+ # Set up Java environment for the next steps
42+ - name : Setup Java
43+ uses : actions/setup-java@v3
44+ with :
45+ distribution : zulu
46+ java-version : 17
47+
48+ # Set environment variables
49+ - name : Export Properties
50+ id : properties
51+ shell : bash
52+ run : |
53+ PROPERTIES="$(./gradlew properties --console=plain -q)"
54+ VERSION="$(echo "$PROPERTIES" | grep "^VERSION_NAME:" | cut -f2- -d ' ')"
55+ chmod +x ./get_changelog.sh
56+ CHANGELOG="$(./get_changelog.sh $VERSION)"
57+ echo "version=$VERSION" >> $GITHUB_OUTPUT
58+ echo "changelog=$(echo "$CHANGELOG" | base64 )" >> $GITHUB_OUTPUT
59+
60+ # Remove old release drafts by using the curl request for the available releases with a draft flag
61+ - name : Remove Old Release Drafts
62+ env :
63+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64+ run : |
65+ gh api repos/{owner}/{repo}/releases \
66+ --jq '.[] | select(.draft == true) | .id' \
67+ | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
68+
69+ # Create a new release draft which is not publicly visible and requires manual acceptance
70+ - name : Create Release Draft
71+ env :
72+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
73+ run : |
74+ gh release create v${{ steps.properties.outputs.version }} \
75+ --draft \
76+ --title "v${{ steps.properties.outputs.version }}" \
77+ --notes "$(echo "${{ steps.properties.outputs.changelog }}" | base64 --decode)"
0 commit comments