generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (157 loc) · 6.39 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# GitHub Actions Workflow created for handling the release process based on the draft release prepared
# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided.
name: Release
on:
release:
types: [prereleased, released]
jobs:
buildRustLibrary:
name: Create Rust Library Artifact
runs-on: ubuntu-latest
container:
image: rust:alpine
steps:
- name: Fetch Sources
uses: actions/checkout@v4
- name: Setup dependencies
shell: sh
working-directory: ./jrad
run: |
apk update && apk add --no-cache git musl-dev xz asciidoctor zig
xz -d -c macos-sdk-11.3.tar.xz | tar -x
echo "SDKROOT=${{ github.workspace }}/jrad/macos-sdk-11.3" >> $GITHUB_ENV
- name: Install zig
shell: sh
working-directory: ./jrad
run: |
rustup target add \
x86_64-unknown-linux-gnu \
aarch64-unknown-linux-gnu \
x86_64-apple-darwin \
aarch64-apple-darwin
# cargo install cargo-zigbuild@0.19.3
cargo install cargo-zigbuild
- name: Build library artifacts
shell: sh
working-directory: ./jrad
run: |
cargo zigbuild --locked --release \
--target=x86_64-apple-darwin \
--target=aarch64-apple-darwin \
--target=x86_64-unknown-linux-gnu \
--target=aarch64-unknown-linux-gnu
- name: Gather artifacts for upload
shell: sh
run: |
mkdir -p ./artifacts
cp ./jrad/target/aarch64-unknown-linux-gnu/release/libjrad.so ./artifacts/aarch64_libjrad.so
cp ./jrad/target/aarch64-unknown-linux-gnu/release/jrad ./artifacts/aarch64_jrad
cp ./jrad/target/aarch64-apple-darwin/release/libjrad.dylib ./artifacts/aarch64_libjrad.dylib
cp ./jrad/target/x86_64-apple-darwin/release/libjrad.dylib ./artifacts/x86_64_libjrad.dylib
cp ./jrad/target/x86_64-unknown-linux-gnu/release/libjrad.so ./artifacts/x86_64_libjrad.so
cp ./jrad/target/x86_64-unknown-linux-gnu/release/jrad ./artifacts/x86_64_jrad
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: jrad
path: artifacts
# Prepare and publish the plugin to the Marketplace repository
release:
name: Publish Plugin
runs-on: ubuntu-latest
needs: buildRustLibrary
permissions:
contents: write
pull-requests: write
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
# Setup Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 21
- name: Install Radicle
env:
RAD_HOME: ${{ github.workspace }}/.radicle
run: |
curl -sSf https://radicle.xyz/install | sh
echo "${RAD_HOME}/bin" >> $GITHUB_PATH
echo "RAD_HOME=${{ github.workspace }}/.radicle" >> $GITHUB_ENV
- name: Extract Changelog
id: changelog
shell: bash
run: |
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
${{ github.event.release.body }}
EOM
)"
# remove empty lines, otherwise changelog plugin will lose rest of content
CHANGELOG="$(echo "$CHANGELOG" | grep -v '^$')"
if [[ "${CHANGELOG}" == "" ]]; then
echo "ERROR! Empty changelog! Aborting release!"
exit 1
fi
echo 'changelog<<EOF' >> $GITHUB_OUTPUT
echo "${CHANGELOG}" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
# Update Unreleased section with the current release note
- name: Patch Changelog
if: ${{ steps.changelog.outputs.changelog != '' }}
env:
CHANGELOG: ${{ steps.changelog.outputs.changelog }}
run: |
echo "patching changelog with: $CHANGELOG"
./gradlew :patchChangelog --release-note="$CHANGELOG"
# Create pull request with changelog update
- name: Push changelog update
if: ${{ steps.changelog.outputs.changelog != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ github.event.release.tag_name }}"
git config user.email "action@github.com"
git config user.name "GitHub Action"
git checkout -b main
git commit -am "Changelog update - $VERSION
Signed-off-by: github-actions <action@github.com>
"
git push --set-upstream origin main
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: jrad
path: ./artifacts
- name: Copy jrad libraries/binaries
run: |
mkdir -p ./src/main/resources/META-INF/jrad/aarch64
mkdir -p ./src/main/resources/META-INF/jrad/x86_64
cp ./artifacts/aarch64_libjrad.so ./src/main/resources/META-INF/jrad/aarch64/libjrad.so
cp ./artifacts/aarch64_jrad ./src/main/resources/META-INF/jrad/aarch64/jrad
cp ./artifacts/aarch64_libjrad.dylib ./src/main/resources/META-INF/jrad/aarch64/libjrad.dylib
cp ./artifacts/x86_64_libjrad.dylib ./src/main/resources/META-INF/jrad/x86_64/libjrad.dylib
cp ./artifacts/x86_64_libjrad.so ./src/main/resources/META-INF/jrad/x86_64/libjrad.so
cp ./artifacts/x86_64_jrad ./src/main/resources/META-INF/jrad/x86_64/jrad
ls -R ./src/main/resources/META-INF
# Publish the plugin to the Marketplace
- name: Publish Plugin
env:
# PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
PUBLISH_TOKEN: ${{ secrets.CYTECH_PUBLISH_TOKEN }}
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
run: |
./gradlew :publishPlugin
# Upload artifact as a release asset
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.event.release.tag_name }} ./build/distributions/* --clobber
zip -r jrad.zip ./artifacts
gh release upload ${{ github.event.release.tag_name }} ./jrad.zip --clobber