Skip to content

Commit f6baea3

Browse files
authored
Create release.yml
1 parent dcc88d3 commit f6baea3

File tree

1 file changed

+165
-0
lines changed

1 file changed

+165
-0
lines changed

.github/workflows/release.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
check_code: # Validates the code
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Set up JDK
18+
uses: actions/setup-java@v3
19+
with:
20+
java-version: '17'
21+
distribution: 'temurin'
22+
cache: 'gradle'
23+
24+
- name: Build
25+
run: ./gradlew build buildPlugin --info
26+
27+
- name: Check for uncommited changes
28+
run: |
29+
if [[ "$(git status --porcelain)" != "" ]]; then
30+
echo ----------------------------------------
31+
echo git status
32+
echo ----------------------------------------
33+
git status
34+
echo ----------------------------------------
35+
echo git diff
36+
echo ----------------------------------------
37+
git diff
38+
echo ----------------------------------------
39+
echo Troubleshooting
40+
echo ----------------------------------------
41+
echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && mvn -B clean package"
42+
exit 1
43+
fi
44+
45+
prepare_release:
46+
runs-on: ubuntu-latest
47+
needs: [check_code]
48+
outputs:
49+
upload_url: ${{ steps.create_release.outputs.upload_url }}
50+
steps:
51+
- uses: actions/checkout@v3
52+
53+
- name: Configure Git
54+
run: |
55+
git config --global user.email "[email protected]"
56+
git config --global user.name "GitHub Actions"
57+
58+
- name: UN-Snap version and output
59+
run: |
60+
originalVersion=$(grep -Po 'pluginVersion=\K.*' gradle.properties)
61+
newVersion="$(echo $originalVersion | cut -d '-' -f1)"
62+
echo "New version: $newVersion"
63+
sed -i "s/pluginVersion=$originalVersion/pluginVersion=$newVersion/" gradle.properties
64+
65+
echo "release=$version" >> $GITHUB_OUTPUT
66+
echo "releasenumber=${version//[!0-9]/}" >> $GITHUB_OUTPUT
67+
68+
echo "Contents of gradle.properties"
69+
cat gradle.properties
70+
71+
- name: Commit and Push
72+
run: |
73+
git add -A
74+
git commit -m "Release ${{ steps.version.outputs.release }}"
75+
git push origin
76+
git tag v${{ steps.version.outputs.release }}
77+
git push origin --tags
78+
79+
- name: Create Release
80+
id: create_release
81+
uses: shogo82148/actions-create-release@v1
82+
with:
83+
tag_name: v${{ steps.version.outputs.release }}
84+
release_name: v${{ steps.version.outputs.release }}
85+
commitish: master
86+
body: |
87+
## [Changelog](https://github.com/xdev-software/${{ github.event.repository.name }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }})
88+
See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/xdev-software/${{ github.event.repository.name }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information.
89+
90+
## Installation
91+
The plugin is listed on the [Marketplace](https://plugins.jetbrains.com/plugin/22113).
92+
93+
Open the plugin Marketplace in your IDE (``File > Settings > Plugins > Marketplace``), search for the plugin and hit the install button.
94+
95+
Alternatively you can also download the jar from the marketplace website.
96+
```
97+
98+
publish:
99+
runs-on: ubuntu-latest
100+
needs: [prepare_release]
101+
steps:
102+
- uses: actions/checkout@v3
103+
104+
- name: Set up JDK
105+
uses: actions/setup-java@v3
106+
with:
107+
distribution: 'temurin'
108+
java-version: 17
109+
cache: 'gradle'
110+
111+
- name: Init Git and pull
112+
run: |
113+
git config --global user.email "[email protected]"
114+
git config --global user.name "GitHub Actions"
115+
git pull
116+
117+
- name: Publish Plugin
118+
env:
119+
PUBLISH_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_PUBLISH_TOKEN }}
120+
CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_MARKETPLACE_CERTIFICATE_CHAIN }}
121+
PRIVATE_KEY: ${{ secrets.JETBRAINS_MARKETPLACE_PRIVATE_KEY }}
122+
PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_MARKETPLACE_PRIVATE_KEY_PASSWORD }}
123+
run: ./gradlew publishPlugin --info --stacktrace
124+
125+
- name: Upload plugin files
126+
uses: actions/upload-artifact@v3
127+
with:
128+
name: plugin-files-java-${{ matrix.java }}
129+
path: build/distributions/*
130+
if-no-files-found: error
131+
132+
after_release:
133+
runs-on: ubuntu-latest
134+
needs: [publish]
135+
steps:
136+
- uses: actions/checkout@v3
137+
138+
- name: Init Git and pull
139+
run: |
140+
git config --global user.email "[email protected]"
141+
git config --global user.name "GitHub Actions"
142+
git pull
143+
144+
- name: Inc Version and SNAP root
145+
run: |
146+
originalVersion=$(grep -Po 'pluginVersion=\K.*' gradle.properties)
147+
newVersion="$(echo $originalVersion | cut -d '-' -f1 | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{$NF=sprintf("%0*d", length($NF), ($NF+1)); print}')-SNAPSHOT"
148+
echo "New version: $newVersion"
149+
sed -i "s/pluginVersion=$originalVersion/pluginVersion=$newVersion/" gradle.properties
150+
151+
echo "Contents of gradle.properties"
152+
cat gradle.properties
153+
154+
- name: Git Commit and Push
155+
run: |
156+
git add -A
157+
git commit -m "Preparing for next development iteration"
158+
git push origin
159+
160+
- name: pull-request
161+
uses: repo-sync/pull-request@v2
162+
with:
163+
destination_branch: "develop"
164+
pr_title: "Sync back"
165+
pr_body: "An automated PR to sync changes back"

0 commit comments

Comments
 (0)