-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (175 loc) · 7.37 KB
/
release.yaml
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
191
192
193
194
195
196
197
198
199
200
name: Build and Release
on:
push:
tags:
- 'v*.*.*' # Triggers on version tags like v0.2.0
workflow_dispatch: # Allows manual triggering
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
os_name: linux
arch: x64
arch_name: amd64
extension: tar.gz
- os: ubuntu-latest
os_name: linux
arch: arm64
arch_name: arm64
extension: tar.gz
- os: windows-latest
os_name: windows
arch: x64
arch_name: amd64
extension: zip
- os: macos-latest
os_name: darwin
arch: x64
arch_name: amd64
extension: tar.gz
- os: macos-latest
os_name: darwin
arch: arm64
arch_name: arm64
extension: tar.gz
runs-on: ${{ matrix.os }}
outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
# Step to extract the version number
- name: Set Version
id: get_version
shell: bash
run: |
VERSION="${GITHUB_REF#refs/tags/}"
VERSION="${VERSION#v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
# Setup QEMU and Docker Buildx for Linux builds
- name: Setup QEMU
if: matrix.os_name == 'linux'
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
if: matrix.os_name == 'linux'
uses: docker/setup-buildx-action@v3
# Build Linux binaries using Docker
- name: Build Linux Binary with Docker
if: matrix.os_name == 'linux'
run: |
mkdir -p /tmp/output
docker buildx build --platform linux/${{ matrix.arch_name }} \
--output type=local,dest=/tmp/output \
--build-arg ARCH=${{ matrix.arch_name }} \
--build-arg VERSION=${{ env.VERSION }} \
-t hf_to_cb_dataset_migrator:linux-${{ matrix.arch_name }} -f Dockerfile.linux .
# Build Windows binary on Windows runner
- name: Set up Python on Windows
if: runner.os == 'Windows'
uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: ${{ matrix.arch }}
- name: Install dependencies on Windows
if: runner.os == 'Windows'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build with PyInstaller on Windows
if: runner.os == 'Windows'
run: |
pyinstaller hf_to_cb_dataset_migrator/cli.py --name hf_to_cb_dataset_migrator
- name: Compress Windows Binary
if: runner.os == 'Windows'
shell: powershell
run: |
$APP_NAME = "hf_to_cb_dataset_migrator_${{ env.VERSION }}_${{ matrix.os_name }}_${{ matrix.arch_name }}"
Compress-Archive -Path dist\hf_to_cb_dataset_migrator\* -DestinationPath "$APP_NAME.${{ matrix.extension }}"
# Build macOS binaries using macOS runners
- name: Set up Python on macOS
if: matrix.os_name == 'darwin'
uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: ${{ matrix.arch }}
- name: Install dependencies on macOS
if: matrix.os_name == 'darwin'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build with PyInstaller on macOS and Code-sign and notarise
if: matrix.os_name == 'darwin'
env:
ARCHFLAGS: ${{ matrix.arch == 'arm64' && '-arch arm64' || '' }}
CERTIFICATE: ${{ secrets.APPLE_DEV_CERT }}
CERT_PASSWORD: ${{ secrets.APPLE_DEV_CERT_PASSPHRASE }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
echo "$CERTIFICATE" | base64 --decode > /tmp/certificate.p12
security create-keychain -p $KEYCHAIN_PASSWORD build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p $KEYCHAIN_PASSWORD build.keychain
security import /tmp/certificate.p12 -k build.keychain -P "$CERT_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k $KEYCHAIN_PASSWORD build.keychain
# build the binary and signin with certificate
pyinstaller hf_to_cb_dataset_migrator/cli.py --name hf_to_cb_dataset_migrator
find dist/hf_to_cb_dataset_migrator -type f \( -perm -111 -o -name "*.dylib" -o -name "*.so" \) -exec \
codesign --remove-signature {} \;
codesign --force --options runtime --timestamp --entitlements ./entitlements.plist \
--sign "Developer ID Application: Couchbase, Inc. ($APPLE_TEAM_ID)" \
dist/hf_to_cb_dataset_migrator/hf_to_cb_dataset_migrator
find dist/hf_to_cb_dataset_migrator -type f \( -perm -111 -o -name "*.dylib" -o -name "*.so" \) -exec \
codesign --force --options runtime --timestamp --entitlements ./entitlements.plist \
--sign "Developer ID Application: Couchbase, Inc. ($APPLE_TEAM_ID)" {} \;
# Verify the code-signing
codesign --verify --strict --verbose dist/hf_to_cb_dataset_migrator/hf_to_cb_dataset_migrator
APP_NAME="hf_to_cb_dataset_migrator_${{ env.VERSION }}_${{ matrix.os_name }}_${{ matrix.arch_name }}"
cd dist
tar -czvf "../$APP_NAME.${{ matrix.extension }}" hf_to_cb_dataset_migrator
ditto -c -k --keepParent hf_to_cb_dataset_migrator "../$APP_NAME.zip"
cd ..
xcrun notarytool submit "$APP_NAME.zip" --apple-id "$APPLE_ID" --password "$APPLE_APP_PASSWORD" --team-id "$APPLE_TEAM_ID" --wait
# Staple the notarization ticket
#xcrun stapler staple "$APP_NAME.zip"
rm -rf "$APP_NAME.zip"
# Compress Linux Binary
- name: Compress Linux Binary
if: matrix.os_name == 'linux'
run: |
APP_NAME="hf_to_cb_dataset_migrator_${{ env.VERSION }}_${{ matrix.os_name }}_${{ matrix.arch_name }}"
tar -czvf "$APP_NAME.${{ matrix.extension }}" -C /tmp/output/dist hf_to_cb_dataset_migrator
# Upload artifact
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os_name }}_${{ matrix.arch_name }}
path: |
hf_to_cb_dataset_migrator_*_${{ matrix.os_name }}_${{ matrix.arch_name }}.*
release:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./artifacts
- name: Create Release and Upload Assets
uses: ncipollo/release-action@v1
with:
tag: ${{ github.ref }}
name: Release ${{ needs.build.outputs.VERSION }}
body: |
Release notes here
artifacts: ./artifacts/**
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false