release fix #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 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-12-arm64 | |
os_name: darwin | |
arch: arm64 | |
arch_name: arm64 | |
extension: tar.gz | |
- 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 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# 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 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
architecture: ${{ matrix.arch }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install pyinstaller | |
- name: Build with PyInstaller in directory mode | |
env: | |
ARCHFLAGS: ${{ runner.os == 'macOS' && matrix.arch == 'arm64' && '-arch arm64' || '' }} | |
run: | | |
pyinstaller your_script.py --name hf_to_cb_dataset_migrator | |
# Code-signing and notarization steps for macOS | |
- name: Code-sign on macOS | |
if: runner.os == 'macOS' | |
env: | |
CERTIFICATE: ${{ secrets.APPLE_DEV_CERT }} | |
CERT_PASSWORD: ${{ secrets.APPLE_DEV_CERT_PASSPHRASE }} | |
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | |
run: | | |
echo "$CERTIFICATE" | base64 --decode > certificate.p12 | |
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain | |
security import certificate.p12 -k build.keychain -P "$CERT_PASSWORD" -T /usr/bin/codesign | |
security set-keychain-settings -lut 21600 build.keychain | |
security list-keychains -s build.keychain | |
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain | |
# Sign the main executable | |
codesign --force --options runtime --sign "Developer ID Application: Your Name (Team ID)" dist/hf_to_cb_dataset_migrator/hf_to_cb_dataset_migrator | |
# Sign all dynamic libraries and executables | |
find dist/hf_to_cb_dataset_migrator -type f \( -name "*.so" -or -name "*.dylib" -or -perm -u=x \) -exec codesign --force --options runtime --sign "Developer ID Application: Your Name (Team ID)" {} \; | |
# Verify the code-signing | |
codesign --verify --deep --strict --verbose=2 dist/hf_to_cb_dataset_migrator/hf_to_cb_dataset_migrator | |
# Compression and notarization for macOS | |
- name: Compress Application Directory on macOS | |
if: runner.os == 'macOS' | |
shell: bash | |
env: | |
VERSION: ${{ env.VERSION }} | |
run: | | |
APP_NAME="hf_to_cb_dataset_migrator_${VERSION}_${{ matrix.os_name }}_${{ matrix.arch_name }}" | |
cd dist | |
zip -r "../$APP_NAME.zip" hf_to_cb_dataset_migrator | |
- name: Notarize the macOS binary | |
if: runner.os == 'macOS' | |
env: | |
APPLE_ID: ${{ secrets.APPLE_ID }} | |
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }} | |
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
VERSION: ${{ env.VERSION }} | |
run: | | |
APP_NAME="hf_to_cb_dataset_migrator_${VERSION}_${{ matrix.os_name }}_${{ matrix.arch_name }}" | |
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" | |
# Compression for Linux | |
- name: Compress Application Directory on Linux | |
if: runner.os == 'Linux' | |
shell: bash | |
env: | |
VERSION: ${{ env.VERSION }} | |
run: | | |
APP_NAME="hf_to_cb_dataset_migrator_${VERSION}_${{ matrix.os_name }}_${{ matrix.arch_name }}" | |
tar -czvf "$APP_NAME.${{ matrix.extension }}" -C dist hf_to_cb_dataset_migrator | |
# Compression for Windows | |
- name: Compress Application Directory on Windows | |
if: runner.os == 'Windows' | |
shell: powershell | |
env: | |
VERSION: ${{ env.VERSION }} | |
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 }}" | |
- 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 }}.* | |
- name: Create Release | |
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Release Asset | |
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: | | |
hf_to_cb_dataset_migrator_*_${{ matrix.os_name }}_${{ matrix.arch_name }}.* | |
asset_name: hf_to_cb_dataset_migrator_${{ env.VERSION }}_${{ matrix.os_name }}_${{ matrix.arch_name }}.${{ matrix.extension }} | |
asset_content_type: application/octet-stream | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |