-
-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (170 loc) · 6.46 KB
/
Copy pathrelease-prebuilt-libs.yml
File metadata and controls
190 lines (170 loc) · 6.46 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Release Prebuilt Libraries
on:
release:
types:
- published
workflow_dispatch:
inputs:
tag:
description: Tag name to upload assets to, for example v1.0.0
required: true
type: string
permissions:
contents: write
jobs:
build-linux-x64:
name: Build Linux x64
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install build tools
run: sudo apt-get update && sudo apt-get install -y build-essential curl autoconf automake libtool pkg-config git
- name: Compile shared library
run: bash build/compile-linux.sh
- name: Create release archive
run: tar -czf build/libpostal-linux-x64.tar.gz -C postalkit/libs/linux-x64 libpostal.so
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: libpostal-linux-x64
path: build/libpostal-linux-x64.tar.gz
build-linux-arm64:
name: Build Linux arm64
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- name: Install build tools
run: sudo apt-get update && sudo apt-get install -y build-essential curl autoconf automake libtool pkg-config git
- name: Compile shared library
run: bash build/compile-linux.sh
- name: Create release archive
run: tar -czf build/libpostal-linux-arm64.tar.gz -C postalkit/libs/linux-arm64 libpostal.so
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: libpostal-linux-arm64
path: build/libpostal-linux-arm64.tar.gz
build-macos-x64:
name: Build macOS x64
runs-on: macos-15-intel
steps:
- uses: actions/checkout@v4
- name: Install build tools
run: brew install autoconf automake libtool pkg-config
- name: Compile shared library
run: bash build/compile-macos.sh
- name: Create release archive
run: tar -czf build/libpostal-macos-x64.tar.gz -C postalkit/libs/macos-x64 libpostal.dylib
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: libpostal-macos-x64
path: build/libpostal-macos-x64.tar.gz
build-macos-arm64:
name: Build macOS arm64
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Install build tools
run: brew install autoconf automake libtool pkg-config
- name: Compile shared library
run: bash build/compile-macos.sh
- name: Create release archive
run: tar -czf build/libpostal-macos-arm64.tar.gz -C postalkit/libs/macos-arm64 libpostal.dylib
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: libpostal-macos-arm64
path: build/libpostal-macos-arm64.tar.gz
build-windows-x64:
name: Build Windows x64
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: base-devel mingw-w64-x86_64-toolchain autoconf automake libtool git
- name: Compile shared library
shell: msys2 {0}
run: bash build/compile-windows.sh
- name: Create release archive
shell: pwsh
run: Compress-Archive -Path postalkit\libs\windows-x64\postal.dll -DestinationPath build\libpostal-windows-x64.zip -Force
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: libpostal-windows-x64
path: build/libpostal-windows-x64.zip
upload-release-assets:
name: Upload Release Assets & Commit to Repo
needs: [build-linux-x64, build-linux-arm64, build-macos-x64, build-macos-arm64, build-windows-x64]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate Checksums
run: |
cd dist
for file in *; do sha256sum "$file" > "${file}.sha256"; done
- name: Resolve target tag
id: target
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
fi
- name: Attach assets to GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.target.outputs.tag }}
files: dist/*
fail_on_unmatched_files: true
- name: Commit Binaries to Repository
run: |
# 1. Clean out archives from the folders
mkdir -p postalkit/libs/linux-x64 postalkit/libs/linux-arm64 postalkit/libs/macos-x64 postalkit/libs/macos-arm64 postalkit/libs/windows-x64
# 2. Extract the actual library files into their git folders
tar -xzf dist/libpostal-linux-x64.tar.gz -C postalkit/libs/linux-x64
tar -xzf dist/libpostal-linux-arm64.tar.gz -C postalkit/libs/linux-arm64
tar -xzf dist/libpostal-macos-x64.tar.gz -C postalkit/libs/macos-x64
tar -xzf dist/libpostal-macos-arm64.tar.gz -C postalkit/libs/macos-arm64
unzip -o dist/libpostal-windows-x64.zip -d postalkit/libs/windows-x64
# 3. Push to main branch
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add --force postalkit/libs/
git commit -m "chore: populate prebuilt binaries in libs/ directory [skip ci]" || echo "No changes to commit"
git push origin main
publish-to-pypi:
name: Publish Final Package to PyPI
needs: [upload-release-assets]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
ref: main # Pull the latest main with the committed binaries
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install build tools
run: python -m pip install --upgrade pip build
- name: Build and Publish
run: |
python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1