changelog fix #38
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: 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 | |
- 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 | |
# Linux-specific steps | |
- 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 | |
- 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 . | |
- 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 | |
# Windows-specific steps | |
- 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 }}" | |
# macOS-specific steps | |
- 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: Create x86_64 venv on macOS (for x64 architecture only) | |
if: matrix.os_name == 'darwin' && matrix.arch == 'x64' | |
run: | | |
# Create x86_64 venv | |
arch -x86_64 python3 -m venv venv_x86 | |
source venv_x86/bin/activate | |
arch -x86_64 python3 -m pip install --upgrade pip | |
arch -x86_64 python3 -m pip install -r requirements.txt | |
arch -x86_64 python3 -m pip install pyinstaller | |
- name: Install dependencies on macOS (for arm64 architecture) | |
if: matrix.os_name == 'darwin' && matrix.arch == 'arm64' | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install -r requirements.txt | |
python -m pip install pyinstaller | |
- name: Build with PyInstaller on macOS and Code-sign and notarize | |
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 | |
# Conditional to set architecture for PyInstaller build | |
if [ "${{ matrix.arch }}" = "x64" ]; then | |
# Activate x86_64 venv and build binary | |
source venv_x86/bin/activate | |
arch -x86_64 pyinstaller hf_to_cb_dataset_migrator/cli.py --name hf_to_cb_dataset_migrator | |
else | |
pyinstaller hf_to_cb_dataset_migrator/cli.py --name hf_to_cb_dataset_migrator | |
fi | |
# Code-signing and notarizing | |
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 | |
rm -rf "$APP_NAME.zip" | |
# 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: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.21.4' | |
- name: Generate Changelog | |
run: | | |
go install github.com/git-chglog/git-chglog/cmd/[email protected] | |
# Generate the changelog using git-chglog and store it in a temporary file | |
git-chglog -c ./.chglog/config-action.yml -o /tmp/changelog.md | |
- name: Create Release and Upload Assets | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ github.ref }} | |
name: Release ${{ needs.build.outputs.VERSION }} | |
bodyFile: /tmp/changelog.md | |
artifacts: ./artifacts/** | |
token: ${{ secrets.GITHUB_TOKEN }} | |
draft: false | |
prerelease: false |