Skip to content

Commit 6af500a

Browse files
committed
Sign OSX bundle
1 parent 472a94c commit 6af500a

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

.github/workflows/cd.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
deploy:
1313
env:
1414
B2_PYPI_PASSWORD: ${{ secrets.B2_PYPI_PASSWORD }}
15+
ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
1516
runs-on: ubuntu-latest
1617
outputs:
1718
upload_url: ${{ steps.create-release.outputs.upload_url }}
@@ -40,7 +41,7 @@ jobs:
4041
tag_name: ${{ github.ref }}
4142
release_name: ${{ steps.build.outputs.version }}
4243
body: ${{ steps.read-changelog.outputs.log_entry }}
43-
draft: false
44+
draft: ${{ env.ACTIONS_STEP_DEBUG == 'true' }}
4445
prerelease: false
4546
- name: Upload the distribution to GitHub
4647
uses: actions/upload-release-asset@v1
@@ -57,6 +58,10 @@ jobs:
5758
password: ${{ env.B2_PYPI_PASSWORD }}
5859
deploy-bundle:
5960
needs: deploy
61+
env:
62+
B2_OSX_CODE_SIGNING_CERTIFICATE: ${{ secrets.B2_OSX_CODE_SIGNING_CERTIFICATE }}
63+
B2_OSX_CODE_SIGNING_CERTIFICATE_NAME: ${{ secrets.B2_OSX_CODE_SIGNING_CERTIFICATE_NAME }}
64+
B2_OSX_CODE_SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.B2_OSX_CODE_SIGNING_CERTIFICATE_PASSWORD }}
6065
runs-on: ${{ matrix.os }}
6166
strategy:
6267
fail-fast: false
@@ -75,6 +80,15 @@ jobs:
7580
- name: Bundle the distribution
7681
id: bundle
7782
run: nox -vs bundle
83+
- name: Import certificate
84+
if: ${{ env.B2_OSX_CODE_SIGNING_CERTIFICATE != '' && runner.os == 'macOS' }}
85+
uses: apple-actions/import-codesign-certs@v1
86+
with:
87+
p12-file-base64: ${{ env.B2_OSX_CODE_SIGNING_CERTIFICATE }}
88+
p12-password: ${{ env.B2_OSX_CODE_SIGNING_CERTIFICATE_PASSWORD }}
89+
- name: Sign the bundle
90+
if: ${{ env.B2_OSX_CODE_SIGNING_CERTIFICATE != '' && runner.os == 'macOS' }}
91+
run: nox -vs sign -- --sign '${{ env.B2_OSX_CODE_SIGNING_CERTIFICATE_NAME }}'
7892
- name: Upload the distribution to GitHub
7993
uses: actions/upload-release-asset@v1
8094
with:

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Added
10+
* Sign OSX binary
11+
912
### Fixed
1013
* Exclude packages inside the test package when installing
1114

noxfile.py

+31-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
REQUIREMENTS_TEST = ['pytest==6.1.1', 'pytest-cov==2.10.1']
3030
REQUIREMENTS_BUILD = ['setuptools>=20.2']
3131

32+
OSX_BUNDLE_IDENTIFIER = 'com.backblaze.b2'
33+
3234
nox.options.reuse_existing_virtualenvs = True
3335
nox.options.sessions = [
3436
'lint',
@@ -169,6 +171,12 @@ def bundle(session):
169171
session.install('pyinstaller')
170172
session.run('rm', '-rf', 'build', 'dist', 'b2.egg-info', external=True)
171173
install_myself(session)
174+
175+
system = platform.system().lower()
176+
177+
if system == 'darwin':
178+
session.posargs.extend(['--osx-bundle-identifier', OSX_BUNDLE_IDENTIFIER])
179+
172180
session.run('pyinstaller', '--onefile', *session.posargs, 'b2.spec')
173181

174182
# Set outputs for GitHub Actions
@@ -177,11 +185,33 @@ def bundle(session):
177185
print('::set-output name=asset_path::', asset_path, sep='')
178186

179187
name, ext = os.path.splitext(os.path.basename(asset_path))
180-
system = platform.system().lower()
181188
asset_name = '{}-{}{}'.format(name, system, ext)
182189
print('::set-output name=asset_name::', asset_name, sep='')
183190

184191

192+
@nox.session(python=False)
193+
def sign(session):
194+
"""Sign the bundled distribution (OSX only)."""
195+
system = platform.system().lower()
196+
197+
if system != 'darwin':
198+
session.skip('signing process is for OSX only')
199+
200+
session.run('security', 'find-identity', external=True)
201+
session.run(
202+
'codesign',
203+
'--force',
204+
'--verbose',
205+
'--timestamp',
206+
'--identifier',
207+
OSX_BUNDLE_IDENTIFIER,
208+
*session.posargs,
209+
'dist/b2',
210+
external=True
211+
)
212+
session.run('codesign', '--verify', '--verbose', 'dist/b2', external=True)
213+
214+
185215
@nox.session(python=PYTHON_DEFAULT_VERSION)
186216
def doc(session):
187217
"""Build the documentation."""

0 commit comments

Comments
 (0)