1
- name : Generate changelog and plugin archive for new release
1
+ name : Release Plugin
2
+ run-name : Release ${{ inputs.release_version }}
3
+
4
+ # Only one job at a time
5
+ concurrency : release
6
+
2
7
on :
3
- push :
4
- tags :
5
- - ' *'
8
+ workflow_dispatch :
9
+ inputs :
10
+ publishToMarketPlace :
11
+ description : ' Publish to JetBrains Marketplace ?'
12
+ required : true
13
+ type : choice
14
+ options :
15
+ - ' true'
16
+ - ' false'
17
+ default : ' false'
18
+ release_version :
19
+ description : ' Release version'
20
+ required : true
21
+ type : string
22
+
6
23
jobs :
7
- build :
24
+ # Prepare and publish the plugin to JetBrains Marketplace repository
25
+ release :
26
+ name : Publish new release
8
27
runs-on : ubuntu-latest
28
+ permissions :
29
+ contents : write
30
+ pull-requests : write
9
31
steps :
10
- - uses : actions/checkout@v2
11
- - name : Set up JDK 11
12
- uses : actions/setup-java@v1
32
+ # Check out current repository
33
+ - name : Fetch Sources
34
+ uses : actions/checkout@v4
35
+
36
+ # Set up Java environment for the next steps
37
+ - name : Setup Java
38
+ uses : actions/setup-java@v4
13
39
with :
14
- java-version : 11
15
- - name : Grant execute permission for gradlew
16
- run : chmod +x gradlew
17
- - name : Build with Gradle
18
- run : ./gradlew buildPlugin
19
- - name : Get the version
20
- id : get_version
21
- run : echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
40
+ distribution : ' temurin'
41
+ java-version : 17
42
+
43
+ # Setup Gradle
44
+ - name : Setup Gradle
45
+ uses : gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
46
+ with :
47
+ add-job-summary : ' on-failure'
48
+ add-job-summary-as-pr-comment : ' on-failure'
49
+ validate-wrappers : true
50
+ gradle-home-cache-cleanup : true
51
+
52
+ - name : Tag Release
53
+ env :
54
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
55
+ run : |
56
+ git config user.email "[email protected] "
57
+ git config user.name "GitHub Action"
58
+ if git diff --quiet; then
59
+ echo "No changes to commit."
60
+ else
61
+ git commit -sam "chore(skip-release): set version to ${{ inputs.release_version }}"
62
+ fi
63
+ git tag ${{ inputs.release_version }}
64
+ git push origin ${{ inputs.release_version }}
65
+
66
+ - name : Set Release Version
67
+ shell : bash
68
+ run : |
69
+ CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2)
70
+ NEW_VERSION=${{ inputs.release_version }}.${{ github.run_number }}
71
+ awk -v current="$CURRENT_VERSION" -v new="$NEW_VERSION" 'BEGIN {FS=OFS="="} $1 == "projectVersion" { $2 = new }1' gradle.properties > tmpfile && mv tmpfile gradle.properties
72
+ echo "Release version: $NEW_VERSION"
73
+ echo "PLUGIN_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
74
+
75
+ # Publish the plugin to JetBrains Marketplace
76
+ - name : Publish Plugin to JetBrains Marketplace
77
+ if : ${{ inputs.publishToMarketPlace == 'true' }}
78
+ env :
79
+ PUBLISH_TOKEN : ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
80
+ run : |
81
+ ./gradlew publishPlugin -PjetBrainsToken=$PUBLISH_TOKEN -PprojectVersion=$PLUGIN_VERSION -PjetBrainsChannel=stable
82
+ echo "Published $PLUGIN_VERSION to the Jetbrains Marketplace"
83
+
84
+ # Set next SNAPSHOT version
85
+ - name : Increment Plugin Version
86
+ shell : bash
87
+ env :
88
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
89
+ run : |
90
+ CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2)
91
+ IFS="-" read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
92
+ IFS="." read -ra VERSION_NUM <<< "${VERSION_PARTS[0]}"
93
+ ((VERSION_NUM[2]+=1))
94
+ NEW_VERSION="${VERSION_NUM[0]}.${VERSION_NUM[1]}.${VERSION_NUM[2]}-SNAPSHOT"
95
+ awk -v new_version="$NEW_VERSION" '/projectVersion=/{sub(/=.*/, "=" new_version)}1' gradle.properties > tmpfile && mv tmpfile gradle.properties
96
+ echo "Set $NEW_VERSION in gradle.properties"
97
+ git checkout -b $NEW_VERSION
98
+ git commit -sam "chore(skip-release): set version to $NEW_VERSION"
99
+ git push -u origin $NEW_VERSION
100
+ gh pr create -B main -H $NEW_VERSION --title "chore(skip-release): set version to $NEW_VERSION" --body 'Created by Github action'
101
+
22
102
- name : Simple conventional changelog
23
103
uses : redhat-developer/simple-conventional-changelog@0a6db1ac3910c2cf66f2e1a530951dba1ece8540 # 0.0.12
24
104
id : changelog
25
105
with :
26
106
token : ${{ secrets.GITHUB_TOKEN }}
27
- current-tag : ${{ steps.get_version.outputs.VERSION }}
107
+ current-tag : ${{ inputs.release_version }}
28
108
types-mapping : ' feat:Features,fix:Bug Fixes,docs:Documentation,refactor:Refactoring,chore:Other'
29
- - run : |
30
- echo '${{ steps.changelog.outputs.changelog }}'
31
- - name : Create Release
32
- id : create_release
33
- uses : actions/create-release@v1
109
+
110
+ # Create a new GitHub release
111
+ - name : Create Github Release
34
112
env :
35
113
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
36
- with :
37
- tag_name : ${{ steps.get_version.outputs.VERSION }}
38
- release_name : ${{ steps.get_version.outputs.VERSION }}
39
- body : ${{ steps.changelog.outputs.changelog }}
40
- - name : Attach zip to release
41
- uses : actions/upload-release-asset@v1
114
+ run : |
115
+ gh release create ${{ inputs.release_version }} \
116
+ --title "${{ inputs.release_version }}" \
117
+ --notes "$(cat << 'EOM'
118
+ ${{ steps.changelog.outputs.changelog }}
119
+ EOM
120
+ )"
121
+
122
+ - name : Upload Release Asset
123
+ if : ${{ inputs.publishToMarketPlace == 'true' }}
42
124
env :
43
125
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
44
- with :
45
- upload_url : ${{ steps.create_release.outputs.upload_url }}
46
- asset_path : ' ${{ github.workspace }}/build/distributions/Telemetry by Red Hat-${{ steps.get_version.outputs.VERSION }}.zip'
47
- asset_name : ' Telemetry by Red Hat-${{ steps.get_version.outputs.VERSION }}.zip'
48
- asset_content_type : application/zip
126
+ run : gh release upload ${{ inputs.release_version }} ./build/distributions/*
0 commit comments