Skip to content

Commit 3f57834

Browse files
authored
Merge pull request #28 from antoniovazquezblanco/ci
Refactor CI
2 parents e97f2e6 + 37f0623 commit 3f57834

File tree

1 file changed

+115
-125
lines changed

1 file changed

+115
-125
lines changed

.github/workflows/main.yml

Lines changed: 115 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -2,136 +2,126 @@ name: Java CI
22

33
on:
44
push:
5+
branches: ['**']
56
pull_request:
67
workflow_dispatch:
8+
release:
9+
types: [published]
710

8-
env:
9-
GHIDRA_VERSION: 10.4
10-
GHIDRA_DATE: 20230928
11+
permissions:
12+
contents: write
1113

1214
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
15+
build-natives:
16+
strategy:
17+
matrix:
18+
os:
19+
- macos-latest
20+
- windows-latest
21+
- ubuntu-latest
22+
23+
runs-on: ${{ matrix.os }}
24+
4325
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]
26+
- name: Clone Repository
27+
uses: actions/checkout@v3
28+
29+
- name: Install Java
30+
uses: actions/setup-java@v4
31+
with:
32+
distribution: 'temurin'
33+
java-version: '17'
34+
35+
- name: Install Ghidra
36+
uses: antoniovazquezblanco/setup-ghidra@v1.2.0
37+
with:
38+
auth_token: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Setup Gradle
41+
uses: gradle/gradle-build-action@v2.11.1
42+
43+
- name: Build natives
44+
run: ./gradlew efidecompressSharedLibrary copyLibraries -PGHIDRA_INSTALL_DIR=${{ env.GHIDRA_INSTALL_DIR }}
45+
46+
- name: Upload natives
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: libefidecompress_${{ matrix.os }}
50+
path: |
51+
os/*/*
52+
!os/*/README.txt
53+
54+
build-extension:
55+
strategy:
56+
matrix:
57+
ghidra:
58+
- "11.0"
59+
- "10.4"
60+
- "10.3.3"
61+
- "10.3.2"
62+
- "10.3.1"
63+
- "10.3"
64+
- "10.2.3"
65+
- "10.2.2"
66+
- "10.2.1"
67+
- "10.2"
68+
69+
needs: build-natives
7070
runs-on: ubuntu-latest
71+
72+
steps:
73+
- name: Clone Repository
74+
uses: actions/checkout@v4
75+
with:
76+
fetch-depth: 0
77+
78+
- name: Install Java
79+
uses: actions/setup-java@v4
80+
with:
81+
distribution: 'temurin'
82+
java-version: '17'
83+
84+
- name: Install Ghidra
85+
uses: antoniovazquezblanco/setup-ghidra@v1.2.0
86+
with:
87+
auth_token: ${{ secrets.GITHUB_TOKEN }}
88+
version: ${{ matrix.ghidra }}
89+
90+
- name: Setup Gradle
91+
uses: gradle/gradle-build-action@v2.11.1
92+
93+
- name: Download precompiled natives
94+
uses: actions/download-artifact@v4
95+
with:
96+
path: os/
97+
merge-multiple: true
98+
99+
- name: Build the plugin
100+
run: ./gradlew -PGHIDRA_INSTALL_DIR=${{ env.GHIDRA_INSTALL_DIR }}
101+
102+
- name: Upload to Artifacts
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: firmware_utils_ghidra_${{ matrix.ghidra }}
106+
path: dist/*.zip
107+
108+
release:
109+
runs-on: "ubuntu-latest"
110+
needs: build-extension
111+
if: github.event_name == 'release'
112+
71113
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 }}
114+
- name: Download binaries
115+
uses: actions/download-artifact@v4
116+
with:
117+
pattern: firmware_utils_ghidra_*
118+
path: dist/
119+
merge-multiple: true
120+
121+
- name: Upload to Releases
122+
uses: svenstaro/upload-release-action@v2
123+
with:
124+
repo_token: ${{ secrets.GITHUB_TOKEN }}
125+
file: dist/*.zip
126+
tag: ${{ github.ref }}
127+
file_glob: true

0 commit comments

Comments
 (0)