Skip to content
This repository was archived by the owner on Aug 4, 2024. It is now read-only.

Commit c92001a

Browse files
committed
Update CI
Change version to 0.0.1
1 parent 6efffc5 commit c92001a

File tree

9 files changed

+291
-92
lines changed

9 files changed

+291
-92
lines changed

.github/workflows/build.yml

Lines changed: 160 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,44 @@
1-
name: build
1+
name: CI/CD
2+
23
on:
34
push:
4-
branches: [ "master" ]
5+
branches:
6+
- master
57
pull_request:
6-
branches: [ "master" ]
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
inputs:
12+
is-a-release:
13+
description: Publish release? (Only works on master, and for untagged versions)
14+
type: boolean
15+
16+
permissions:
17+
contents: write
18+
issues: write
19+
checks: write
20+
pull-requests: write
21+
722
jobs:
8-
build:
23+
test:
24+
name: Run test suite
25+
if: inputs.is-a-release == false
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
os: [ ubuntu-latest ]
30+
java-version: [ 11 ]
931
runs-on: ubuntu-latest
10-
permissions:
11-
contents: read
32+
timeout-minutes: 35
1233
steps:
13-
- uses: actions/checkout@v3
14-
- name: Set up JDK 11
34+
- name: Checkout
35+
uses: actions/checkout@v3
36+
- name: Setup JDK
1537
uses: actions/setup-java@v3
1638
with:
17-
java-version: '11'
18-
distribution: 'temurin'
39+
distribution: temurin
40+
java-version: ${{ matrix.java-version }}
41+
check-latest: true
1942
- name: Install Rust toolchain
2043
uses: actions-rs/toolchain@v1
2144
with:
@@ -41,4 +64,130 @@ jobs:
4164
with:
4265
arguments: test
4366
env:
44-
CSJ_FULL_BUILD: 1
67+
CSJ_FULL_BUILD: 1
68+
- name: Upload test results
69+
if: always()
70+
uses: actions/upload-artifact@v3
71+
with:
72+
name: Test artifacts
73+
retention-days: 21
74+
path: |
75+
**/TEST-*
76+
**/hs_err_pid*
77+
78+
# Publishes the test results of 'test'
79+
publish-test-results:
80+
name: Publish tests results
81+
if: inputs.is-a-release == false
82+
needs: test
83+
runs-on: ubuntu-latest
84+
steps:
85+
- name: Download artifacts
86+
uses: actions/download-artifact@v3
87+
with:
88+
path: artifacts
89+
- name: Publish test results
90+
uses: EnricoMi/publish-unit-test-result-action@v2
91+
with:
92+
check_name: Unit Test results
93+
files: artifacts/unit-test-*/**/*.xml
94+
95+
# Builds the projects and attempts to publish a release if the current project version
96+
# does not match any existing tags in the repository.
97+
build-and-release:
98+
name: Publish release
99+
if: inputs.is-a-release && github.repository == 'native4j/capstone-java' && github.ref == 'refs/heads/master'
100+
strategy:
101+
fail-fast: true
102+
runs-on: ubuntu-latest
103+
timeout-minutes: 35
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@v3
107+
with:
108+
fetch-depth: 0 # Required depth for JReleaser
109+
- name: Setup Java JDK
110+
uses: actions/setup-java@v3
111+
with:
112+
distribution: temurin
113+
java-version: 11
114+
- name: Install Rust toolchain
115+
uses: actions-rs/toolchain@v1
116+
with:
117+
toolchain: stable
118+
- name: Cache osxcross toolchain
119+
uses: actions/cache@v3
120+
with:
121+
path: |
122+
./osxcross/target/
123+
key: ${{ runner.os }}-osxcross-${{ hashFiles('ci-setup.sh') }}
124+
- name: Validate Gradle wrapper
125+
uses: gradle/wrapper-validation-action@v1
126+
- name: Make gradlew executable
127+
run: chmod +x ./gradlew
128+
- name: Download Gradle wrapper
129+
run: ./gradlew --version
130+
- name: Extract project version to environment variable
131+
run: echo "PROJECT_VERSION=$(./gradlew properties | grep -Po '(?<=version\W ).*')" >> $GITHUB_ENV
132+
# Check if a tag exists that matches the current project version.
133+
# Write the existence state to the step output 'tagExists'.
134+
- name: Check the package version has corresponding Git tag
135+
id: tagged
136+
shell: bash
137+
run: |
138+
git show-ref --tags --verify --quiet -- "refs/tags/${{ env.PROJECT_VERSION }}" && echo "tagExists=1" >> $GITHUB_OUTPUT || echo "tagExists=0" >> $GITHUB_OUTPUT
139+
git show-ref --tags --verify --quiet -- "refs/tags/${{ env.PROJECT_VERSION }}" && echo "Tag for current version exists" || echo "Tag for current version does not exist"
140+
# If the tag could not be fetched, show a message and abort the job.
141+
# The wonky if logic is a workaround for: https://github.com/actions/runner/issues/1173
142+
- name: Abort if tag exists, or existence check fails
143+
if: ${{ false && steps.tagged.outputs.tagExists }}
144+
run: |
145+
echo "Output of 'tagged' step: ${{ steps.tagged.outputs.tagExists }}"
146+
echo "Failed to check if tag exists."
147+
echo "PROJECT_VERSION: ${{ env.PROJECT_VERSION }}"
148+
echo "Tags $(git tag | wc -l):"
149+
git tag
150+
git show-ref --tags --verify -- "refs/tags/${{ env.PROJECT_VERSION }}"
151+
exit 1
152+
# Run build to generate the release artifacts.
153+
# Tag does not exist AND trigger was manual. Deploy release artifacts!
154+
- name: Make CI script executable
155+
run: chmod +x ./ci-setup.sh
156+
- name: Execute CI script
157+
run: ./ci-setup.sh
158+
- name: Add osxcross to PATH
159+
run: echo "$(pwd)/osxcross/target/bin" >> $GITHUB_PATH
160+
- name: Test with Gradle
161+
uses: gradle/gradle-build-action@v2
162+
with:
163+
arguments: test
164+
env:
165+
CSJ_FULL_BUILD: 1
166+
- name: Publish with Gradle
167+
uses: gradle/gradle-build-action@v2
168+
with:
169+
arguments: publish
170+
env:
171+
CSJ_FULL_BUILD: 1
172+
# Make release with JReleaser, only running when the project version does not exist as a tag on the repository.
173+
- name: Publish release
174+
uses: jreleaser/release-action@v2
175+
with:
176+
arguments: full-release
177+
env:
178+
JRELEASER_PROJECT_VERSION: ${{ env.PROJECT_VERSION }}
179+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
180+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
181+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
182+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
183+
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_DEPLOY_MAVEN_NEXUS2_USERNAME }}
184+
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_DEPLOY_MAVEN_NEXUS2_PASSWORD }}
185+
# Upload JRelease debug log
186+
- name: JReleaser output
187+
uses: actions/upload-artifact@v3
188+
if: always()
189+
with:
190+
name: jreleaser-release
191+
path: |
192+
out/jreleaser/trace.log
193+
out/jreleaser/output.properties

.github/workflows/publish.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

build.gradle

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
def project_version = "dev"
2-
3-
def version_override = System.getenv("CSJ_VERSION")
4-
if (version_override != null) {
5-
// Remove leading "v" if present
6-
if (version_override.startsWith("v"))
7-
version_override = version_override.substring(1)
8-
project_version = version_override.trim()
9-
}
10-
111
allprojects {
122
group = "org.native4j"
13-
version = project_version
3+
version = "0.0.1"
144
}
155

166
subprojects {

ci-setup.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ sudo apt install -y build-essential \
77
git \
88
wget \
99
cmake \
10+
clang \
1011
mingw-w64 \
1112
gcc-arm-linux-gnueabihf \
1213
gcc-aarch64-linux-gnu \
@@ -31,7 +32,7 @@ setup_osxcross() {
3132
cd osxcross
3233

3334
# Install osxcross dependencies
34-
./tools/get_dependencies.sh
35+
sudo ./tools/get_dependencies.sh
3536

3637
# Download Big Sur 11.1 SDK
3738
wget -nc https://github.com/joseluisq/macosx-sdks/releases/download/11.1/MacOSX11.1.sdk.tar.xz
@@ -40,6 +41,12 @@ setup_osxcross() {
4041
# Build clang
4142
UNATTENDED=yes OSX_VERSION_MIN=11.1 ./build.sh
4243

44+
# Check if target exists
45+
if [ ! -d "target" ]; then
46+
echo "target directory does not exist"
47+
exit 1
48+
fi
49+
4350
cd ../
4451
}
4552

jreleaser.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
project:
2+
name: capstone-java
3+
description: Capstone bindings for Java.
4+
longDescription: Capstone bindings for Java.
5+
links:
6+
homepage: https://github.com/native4j/capstone-java
7+
authors:
8+
- Justin Phelps
9+
license: MIT
10+
inceptionYear: "2023"
11+
copyright: The Native4J Authors
12+
stereotype: NONE
13+
java:
14+
version: "11"
15+
groupId: org.native4j
16+
artifactId: capstone-java
17+
snapshot:
18+
pattern: .*-SNAPSHOT
19+
label: '{{projectVersion}}'
20+
21+
release:
22+
github:
23+
overwrite: true
24+
tagName: '{{projectVersion}}'
25+
changelog:
26+
formatted: ALWAYS
27+
preset: conventional-commits
28+
contributors:
29+
format: '- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}'
30+
31+
distributions:
32+
dist:
33+
type: SINGLE_JAR
34+
artifacts:
35+
- path: native4j-capstone/build/libs/capstone-java-{{projectVersion}}.jar
36+
37+
signing:
38+
active: RELEASE
39+
mode: MEMORY
40+
armored: true
41+
verify: true
42+
artifacts: true
43+
checksums: true
44+
files: false
45+
46+
deploy:
47+
maven:
48+
nexus2:
49+
maven-central:
50+
active: RELEASE
51+
authorization: BASIC
52+
sign: true
53+
url: https://s01.oss.sonatype.org/service/local
54+
snapshotUrl: https://s01.oss.sonatype.org/content/repositories/snapshots/
55+
applyMavenCentralRules: true
56+
stagingRepositories:
57+
- native4j-capstone/build/staging-deploy
58+
closeRepository: false
59+
releaseRepository: false

0 commit comments

Comments
 (0)