Skip to content

Commit 3e0508d

Browse files
Refactor CI
1 parent e97f2e6 commit 3e0508d

File tree

1 file changed

+114
-130
lines changed

1 file changed

+114
-130
lines changed

.github/workflows/main.yml

Lines changed: 114 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,121 @@
11
name: Java CI
22

3-
on:
4-
push:
5-
pull_request:
6-
workflow_dispatch:
7-
8-
env:
9-
GHIDRA_VERSION: 10.4
10-
GHIDRA_DATE: 20230928
3+
on: [push, pull_request, workflow_dispatch]
114

125
jobs:
13-
build-macos:
14-
runs-on: macos-latest
15-
steps:
16-
- uses: actions/checkout@v3
17-
18-
- name: Set up JDK 17
19-
uses: actions/setup-java@v3
20-
with:
21-
java-version: '17'
22-
distribution: 'adopt'
23-
24-
- name: Set up Ghidra
25-
run: |
26-
set -x
27-
curl -L -O "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_${GHIDRA_VERSION}_build/ghidra_${GHIDRA_VERSION}_PUBLIC_${GHIDRA_DATE}.zip"
28-
unzip -q "ghidra_${GHIDRA_VERSION}_PUBLIC_${GHIDRA_DATE}.zip"
29-
echo "GHIDRA_INSTALL_DIR=${PWD}/ghidra_${GHIDRA_VERSION}_PUBLIC" >> $GITHUB_ENV
30-
working-directory: /tmp
31-
32-
- name: Build with Gradle
33-
run: ./gradlew
34-
35-
- name: Upload to Artifacts
36-
uses: actions/upload-artifact@v3
37-
with:
38-
name: libefidecompress.dylib
39-
path: os/mac_x86_64/libefidecompress.dylib
40-
41-
build-windows:
42-
runs-on: windows-latest
6+
build-natives:
7+
strategy:
8+
matrix:
9+
os:
10+
- macos-latest
11+
- windows-latest
12+
- ubuntu-latest
13+
14+
runs-on: ${{ matrix.os }}
15+
4316
steps:
44-
- uses: actions/checkout@v3
45-
46-
- name: Set up JDK 17
47-
uses: actions/setup-java@v3
48-
with:
49-
java-version: '17'
50-
distribution: 'adopt'
51-
52-
- name: Set up Ghidra
53-
run: |
54-
Invoke-WebRequest "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_${env:GHIDRA_VERSION}_build/ghidra_${env:GHIDRA_VERSION}_PUBLIC_${env:GHIDRA_DATE}.zip" -OutFile "ghidra_${env:GHIDRA_VERSION}_PUBLIC_${env:GHIDRA_DATE}.zip"
55-
Expand-Archive "ghidra_${env:GHIDRA_VERSION}_PUBLIC_${env:GHIDRA_DATE}.zip" -DestinationPath .
56-
echo "GHIDRA_INSTALL_DIR=$pwd\ghidra_${env:GHIDRA_VERSION}_PUBLIC" >> ${env:GITHUB_ENV}
57-
working-directory: ${{ env.TEMP }}
58-
59-
- name: Build with Gradle
60-
run: ./gradlew.bat
61-
62-
- name: Upload to Artifacts
63-
uses: actions/upload-artifact@v3
64-
with:
65-
name: efidecompress.dll
66-
path: os/win_x86_64/efidecompress.dll
67-
68-
build-linux:
69-
needs: [build-macos, build-windows]
17+
- name: Clone Repository
18+
uses: actions/checkout@v3
19+
20+
- name: Install Java
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: 'temurin'
24+
java-version: '17'
25+
26+
- name: Install Ghidra
27+
uses: antoniovazquezblanco/setup-ghidra@v1.2.0
28+
with:
29+
auth_token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Setup Gradle
32+
uses: gradle/gradle-build-action@v2.11.1
33+
34+
- name: Build natives
35+
run: ./gradlew efidecompressSharedLibrary copyLibraries -PGHIDRA_INSTALL_DIR=${{ env.GHIDRA_INSTALL_DIR }}
36+
37+
- name: Upload natives
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: libefidecompress_${{ matrix.os }}
41+
path: |
42+
os/*/*
43+
!os/*/README.txt
44+
45+
build-extension:
46+
strategy:
47+
matrix:
48+
ghidra:
49+
- "11.0"
50+
- "10.4"
51+
- "10.3.3"
52+
- "10.3.2"
53+
- "10.3.1"
54+
- "10.3"
55+
- "10.2.3"
56+
- "10.2.2"
57+
- "10.2.1"
58+
- "10.2"
59+
60+
needs: build-natives
7061
runs-on: ubuntu-latest
62+
7163
steps:
72-
- uses: actions/checkout@v3
73-
with:
74-
fetch-depth: 0
75-
76-
- name: Set up JDK 17
77-
uses: actions/setup-java@v3
78-
with:
79-
java-version: '17'
80-
distribution: 'adopt'
81-
82-
- name: Set up Ghidra
83-
run: |
84-
set -x
85-
curl -L -O "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_${GHIDRA_VERSION}_build/ghidra_${GHIDRA_VERSION}_PUBLIC_${GHIDRA_DATE}.zip"
86-
unzip -q "ghidra_${GHIDRA_VERSION}_PUBLIC_${GHIDRA_DATE}.zip"
87-
echo "GHIDRA_INSTALL_DIR=${PWD}/ghidra_${GHIDRA_VERSION}_PUBLIC" >> $GITHUB_ENV
88-
working-directory: /tmp
89-
90-
- name: Download macOS JNI library
91-
uses: actions/download-artifact@v3
92-
with:
93-
name: libefidecompress.dylib
94-
path: os/mac_x86_64
95-
96-
- name: Download Windows JNI library
97-
uses: actions/download-artifact@v3
98-
with:
99-
name: efidecompress.dll
100-
path: os/win_x86_64
101-
102-
- name: Build plugin with Gradle
103-
run: |
104-
set -x
105-
./gradlew
106-
plugin_date=$(find dist -name '*.zip' | awk -F '_' '{print $4}')
107-
last_tag=$(git tag -l "$plugin_date.*" | sort -n | tail -n 1)
108-
if [ ! -z "$last_tag" ]; then
109-
plugin_tag=$(echo "$last_tag" | awk -F '.' '{print $1 "." $2+1}')
110-
else
111-
plugin_tag="$plugin_date.0"
112-
last_tag=$(git tag -l | sort -n | tail -n 1)
113-
if [ -z "$last_tag" ]; then
114-
last_tag=$(git rev-list --max-parents=0 HEAD)
115-
fi
116-
fi
117-
plugin_changelog="$(git log --pretty=format:%s ${last_tag}.. | sed -e 's/^/- /')"
118-
echo "PLUGIN_TAG=${plugin_tag}" >> $GITHUB_ENV
119-
echo "PLUGIN_CHANGELOG<<EOF" >> $GITHUB_ENV
120-
echo "$plugin_changelog" >> $GITHUB_ENV
121-
echo "EOF" >> $GITHUB_ENV
122-
mv dist/*.zip "dist/ghidra_${GHIDRA_VERSION}_PUBLIC_${plugin_tag}_ghidra-firmware-utils.zip"
123-
124-
- name: Upload to Artifacts
125-
uses: actions/upload-artifact@v3
126-
with:
127-
path: dist/*.zip
128-
129-
- name: Upload to Releases
130-
if: ${{ github.ref == 'refs/heads/master' }}
131-
uses: svenstaro/upload-release-action@v2
132-
with:
133-
repo_token: ${{ secrets.GITHUB_TOKEN }}
134-
file: dist/*.zip
135-
tag: ${{ env.PLUGIN_TAG }}
136-
file_glob: true
137-
body: ${{ env.PLUGIN_CHANGELOG }}
64+
- name: Clone Repository
65+
uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0
68+
69+
- name: Install Java
70+
uses: actions/setup-java@v4
71+
with:
72+
distribution: 'temurin'
73+
java-version: '17'
74+
75+
- name: Install Ghidra
76+
uses: antoniovazquezblanco/setup-ghidra@v1.2.0
77+
with:
78+
auth_token: ${{ secrets.GITHUB_TOKEN }}
79+
version: ${{ matrix.ghidra }}
80+
81+
- name: Setup Gradle
82+
uses: gradle/gradle-build-action@v2.11.1
83+
84+
- name: Download precompiled natives
85+
uses: actions/download-artifact@v4
86+
with:
87+
path: os/
88+
merge-multiple: true
89+
90+
- name: Build the plugin
91+
run: ./gradlew -PGHIDRA_INSTALL_DIR=${{ env.GHIDRA_INSTALL_DIR }}
92+
93+
- name: Upload to Artifacts
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: firmware_utils_ghidra_${{ matrix.ghidra }}
97+
path: dist/*.zip
98+
99+
release:
100+
runs-on: "ubuntu-latest"
101+
needs: build-extension
102+
103+
steps:
104+
- name: Get current date
105+
id: date
106+
run: echo "::set-output name=date::$(date +'%Y%m%d')"
107+
108+
- name: Download binaries
109+
uses: actions/download-artifact@v4
110+
with:
111+
pattern: firmware_utils_ghidra_*
112+
path: dist/
113+
merge-multiple: true
114+
115+
- name: Release
116+
if: github.ref == 'refs/heads/main'
117+
uses: marvinpinto/action-automatic-releases@v1.2.1
118+
with:
119+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
120+
title: "${{steps.date.outputs.date}}.0"
121+
files: dist/*.zip

0 commit comments

Comments
 (0)