-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (171 loc) · 7.03 KB
/
Copy pathdraft_release.yml
File metadata and controls
178 lines (171 loc) · 7.03 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Draft Release
on:
workflow_dispatch:
push:
branches: [ main ]
jobs:
buildRustLibrary:
name: Create Rust Library Artifact
runs-on: ubuntu-latest
container:
#image: rust:1.81-alpine3.20
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
buildPluginArtifact:
name: Create Plugin Artifact
runs-on: ubuntu-latest
needs: buildRustLibrary
outputs:
version: ${{ steps.properties.outputs.version }}
filename: ${{ steps.artifact.outputs.filename }}
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v4
# Validate wrapper
- name: Gradle Wrapper Validation
uses: gradle/actions/wrapper-validation@v4
# Setup Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 21
cache: gradle
# Set environment variables
- name: Export Properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "name=$NAME" >> $GITHUB_OUTPUT
- 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: 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
# Prepare plugin archive content for creating artifact
- name: Prepare Plugin Artifact
id: artifact
shell: bash
run: |
# on linux there's a bug that causes buildPlugin to fail the first time: https://youtrack.jetbrains.com/issue/IDEA-291977
./gradlew buildPlugin || ./gradlew buildPlugin
cd ${{ github.workspace }}/build/distributions
FILENAME=$(ls *.zip)
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
# Store already-built plugin as an artifact for downloading
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.filename }}
path: ./build/distributions/${{ steps.artifact.outputs.filename }}.zip
# Prepare a draft release for GitHub Releases page for the manual verification
# If accepted and published, release workflow would be triggered
releaseDraft:
name: Release Draft
if: github.event_name != 'pull_request'
needs: buildPluginArtifact
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v4
# Remove old release drafts by using the curl request for the available releases with draft flag
- name: Remove Old Release Drafts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/{owner}/{repo}/releases \
--jq '.[] | select(.draft == true) | .id' \
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
- name: Download native library
uses: actions/download-artifact@v4
with:
name: jrad
path: ./artifacts
- name: Download built plugin
uses: actions/download-artifact@v4
with:
name: ${{ needs.buildPluginArtifact.outputs.filename }}
path: ./${{ needs.buildPluginArtifact.outputs.filename }}
# Create new release draft - which is not publicly visible and requires manual acceptance
- name: Create Release Draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# zip up the native artifacts
zip -r jrad.zip ./artifacts
zip -r "${{ needs.buildPluginArtifact.outputs.filename }}.zip" "./${{ needs.buildPluginArtifact.outputs.filename }}"
gh release create v${{ needs.buildPluginArtifact.outputs.version }} \
--draft \
--title "v${{ needs.buildPluginArtifact.outputs.version }}" \
--generate-notes \
"./${{ needs.buildPluginArtifact.outputs.filename }}.zip" ./jrad.zip