-
Notifications
You must be signed in to change notification settings - Fork 17
132 lines (121 loc) · 4.61 KB
/
publish.yml
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
name: Publish Tagged Commit to PyPI
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
workflow-ghidra-ver:
description: "Specify Ghidra Version to Build"
required: true
type: string
default: "latest"
schedule:
- cron: "0 13 * * 3"
jobs:
set-versions:
runs-on: ubuntu-20.04
outputs:
ghidra-ver: ${{ env.GHIDRA_VER }}
pyi-ver: ${{ env.PYI_VER }}
pyi-rel-ver: ${{ env.PYI_REL_VER }}
steps:
- if: github.event_name == 'schedule' || github.event.inputs.workflow-ghidra-ver == 'latest'
name: Get Latest Ghidra Version
id: get_latest_ghidra_ver
uses: pozetroninc/github-action-get-latest-release@v0.6.0
with:
repository: NationalSecurityAgency/ghidra
excludes: prerelease, draft
- name: Set Ghidra Version from Latest
if: github.event_name == 'schedule' || github.event.inputs.workflow-ghidra-ver == 'latest'
id: format_ghidra_ver
run: |
echo "GHIDRA_VER=$(echo ${{steps.get_latest_ghidra_ver.outputs.release}} | cut -d_ -f2)" >> $GITHUB_ENV
- name: Set Ghidra Version from Input
if: github.event_name == 'workflow_dispatch' && github.event.inputs.workflow-ghidra-ver != 'latest'
run: |
echo "GHIDRA_VER=$(echo ${{github.event.inputs.workflow-ghidra-ver}})" >> $GITHUB_ENV
- name: Checkout repo
uses: actions/checkout@v3
- name: Get Ghidra Stubs Version
id: get_pyi_ver
run: |
echo "PYI_VER=$(python version.py)" >> $GITHUB_ENV
- name: Get Ghidra Stubs Full Release Version
id: get_pyi_rel_ver
run: |
echo "PYI_REL_VER=$GHIDRA_VER.$PYI_VER" >> $GITHUB_ENV
check-release:
needs:
- set-versions
runs-on: ubuntu-20.04
outputs:
already-exists: ${{ contains( steps.self.outputs.release, needs.set-versions.outputs.pyi-rel-ver ) }}
steps:
- id: self
uses: pozetroninc/github-action-get-latest-release@v0.6.0
with:
repository: ${{ github.repository }}
- name: Print Versions and Already Exists
run: |
echo "Ghidra ver: ${{ needs.set-versions.outputs.ghidra-ver }} PYI ver: ${{ needs.set-versions.outputs.pyi-ver }} PYI Release: ${{needs.set-versions.outputs.pyi-rel-ver}} Current Release: ${{steps.self.outputs.release }}"
echo "already exists ${{ contains( steps.self.outputs.release, needs.set-versions.outputs.pyi-rel-ver ) }}"
build-n-publish:
needs:
- set-versions
- check-release
if: needs.check-release.outputs.already-exists == 'false' || (github.event_name == 'workflow_dispatch' && github.event.inputs.workflow-ghidra-ver != 'latest')
name: Build and publish Python Package
runs-on: ubuntu-20.04
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
# Required for publishing a release on GitHub
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 1.11
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "21"
- uses: er28-0652/setup-ghidra@master
with:
version: "${{ needs.set-versions.outputs.ghidra-ver }}"
- name: Prepare Jython Environment
run: |
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /tmp tmp -scriptPath $(pwd) -preScript vendor_packages.py
- name: Build Package
run: |
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /tmp tmp -scriptPath $(pwd) -preScript generate_ghidra_pyi.py ./ ${{ needs.set-versions.outputs.pyi-ver }}
test -f setup.py # check manually, because analyzeHeadless doesn't fail on script failure
test -d ghidra-stubs
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install pypa/build
run: >-
python -m
pip install
wheel
--user
- name: Build a binary wheel and a source tarball
run: |
python setup.py bdist_wheel --universal
python setup.py sdist
- name: Upload dist as artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Release on GitHub
uses: softprops/action-gh-release@v1
with:
files: ./dist/*
tag_name: "v${{ needs.set-versions.outputs.pyi-rel-ver }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}