Skip to content

Commit 48cf331

Browse files
authored
PSEC-1995: Create release workflow (#18)
1 parent 391cddc commit 48cf331

File tree

4 files changed

+132
-2
lines changed

4 files changed

+132
-2
lines changed

.github/workflows/release.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- release/*
7+
8+
jobs:
9+
build-lib-macos:
10+
runs-on: macos-latest
11+
defaults:
12+
run:
13+
working-directory: ./rust-lib
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Install rust targets
17+
run: rustup target install x86_64-apple-darwin && rustup target install aarch64-apple-darwin
18+
- name: Clean environment
19+
run: cargo clean
20+
- name: Build rust macos Intel lib
21+
run: cargo build --release --target x86_64-apple-darwin
22+
- name: Build rust macos ARM lib
23+
run: cargo build --release --target aarch64-apple-darwin
24+
- name: Create rust macos universal lib
25+
run: lipo -create -output librust_lib.dylib target/x86_64-apple-darwin/release/librust_lib.dylib target/aarch64-apple-darwin/release/librust_lib.dylib
26+
- name: Upload rust macos universal lib
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: librust_lib.dylib
30+
path: ./rust-lib/librust_lib.dylib
31+
32+
build-lib-ubuntu:
33+
runs-on: ubuntu-latest
34+
defaults:
35+
run:
36+
working-directory: ./rust-lib
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: Install rust targets
40+
run: rustup target install x86_64-unknown-linux-gnu
41+
- name: Clean environment
42+
run: cargo clean
43+
- name: Build rust linux lib
44+
run: cargo build --release --target x86_64-unknown-linux-gnu
45+
- name: Upload rust linux lib
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: librust_lib.so
49+
path: ./rust-lib/target/x86_64-unknown-linux-gnu/release/librust_lib.so
50+
51+
build-lib-windows:
52+
runs-on: windows-latest
53+
defaults:
54+
run:
55+
working-directory: ./rust-lib
56+
steps:
57+
- uses: actions/checkout@v4
58+
- name: Install rust targets
59+
run: rustup target install x86_64-pc-windows-msvc
60+
- name: Clean environment
61+
run: cargo clean
62+
- name: Build rust windows lib
63+
run: cargo build --release --target x86_64-pc-windows-msvc
64+
- name: Upload rust windows lib
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: rust_lib.dll
68+
path: ./rust-lib/target/x86_64-pc-windows-msvc/release/rust_lib.dll
69+
70+
build-java-publish:
71+
permissions:
72+
contents: write # needed for creating a release
73+
runs-on: ubuntu-latest
74+
needs: [build-lib-macos, build-lib-ubuntu, build-lib-windows]
75+
defaults:
76+
run:
77+
working-directory: ./java-extension
78+
steps:
79+
- uses: actions/checkout@v4
80+
- name: Download rust macos universal lib
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: librust_lib.dylib
84+
path: ./java-extension/src/main/resources/
85+
- name: Download rust linux lib
86+
uses: actions/download-artifact@v4
87+
with:
88+
name: librust_lib.so
89+
path: ./java-extension/src/main/resources/
90+
- name: Download rust windows lib
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: rust_lib.dll
94+
path: ./java-extension/src/main/resources/
95+
- name: Set up JDK 17
96+
uses: actions/setup-java@v4
97+
with:
98+
java-version: '17'
99+
distribution: 'temurin'
100+
- name: Remove SNAPSHOT from version string
101+
run: sed -i "s|-SNAPSHOT||g" ./build.gradle.kts
102+
- name: Build jar
103+
run: ./gradlew clean jar
104+
- name: Get version from tag
105+
id: get_version
106+
run: echo "version=$(echo $GITHUB_REF | cut -d / -f 4)" >> $GITHUB_OUTPUT
107+
- name: Check version
108+
run: test -f build/libs/ic-burp-extension-${{ steps.get_version.outputs.version }}.jar
109+
- name: Upload jar
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: ic-burp-extension-${{ steps.get_version.outputs.version }}.jar
113+
path: ./java-extension/build/libs/ic-burp-extension-${{ steps.get_version.outputs.version }}.jar
114+
- name: Create release
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
run: gh release create "$GITHUB_REF_NAME" --repo="$GITHUB_REPOSITORY" --title="v${{ steps.get_version.outputs.version }}" --generate-notes --verify-tag --draft ./build/libs/ic-burp-extension-${{ steps.get_version.outputs.version }}.jar

docs/how-to-release.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# How to create a release
2+
1. Make sure the correct version is set in [build.gradle.kts](../java-extension/build.gradle.kts), e.g., `0.1.0-alpha-SNAPSHOT` and it has been pushed to the main branch.
3+
2. Checkout the right commit
4+
```
5+
git checkout 391cddca4537547053cc69057358a43ac74bb8ae
6+
```
7+
3. Create a tag with the name `release/<version>` and push it
8+
```
9+
git tag release/0.1.0-alpha
10+
git push origin release/0.1.0-alpha
11+
```
12+
4. Check if a new [release workflow](https://github.com/dfinity/ic-burp-extension/actions/workflows/release.yml) has been triggered and wait until it has completed. This workflow will build the JAR, create a new draft release and attach the JAR to it.
13+
5. If the workflow has completed successfully a new draft release should be available under [releases](https://github.com/dfinity/ic-burp-extension/releases). Click on the pencil on the upper right corner to edit the release. Verify that all specified information is correct, set the `pre-release` flag if applicable and finally click `Publish release`.

java-extension/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group = "org.dfinity"
6-
version = "0.1-SNAPSHOT"
6+
version = "0.1.0-alpha-SNAPSHOT"
77

88
repositories {
99
mavenCentral()

java-extension/src/main/java/org/dfinity/ic/burp/tools/jna/JnaIcTools.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public DelegationInfo internetIdentityGetDelegation(String anchor, Identity sign
116116

117117
public interface CIcTools extends Library {
118118
String LIB_NAME = "rust_lib";
119-
CIcTools INSTANCE = Native.load((Platform.isMac() ? "lib" : "") + LIB_NAME + "." + (Platform.isWindows() ? "dll" : Platform.isMac() ? "dylib" : "so"), CIcTools.class);
119+
CIcTools INSTANCE = Native.load((Platform.isMac() || Platform.isLinux() ? "lib" : "") + LIB_NAME + "." + (Platform.isWindows() ? "dll" : Platform.isMac() ? "dylib" : "so"), CIcTools.class);
120120

121121
JnaDiscoverCanisterInterfaceResult.ByValue discover_canister_interface(String canisterId);
122122

0 commit comments

Comments
 (0)