Skip to content

Commit

Permalink
[uni] update release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
snowfoxsh committed Feb 25, 2025
1 parent 6cf3b08 commit 9a91e1a
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Handle Release
on:
workflow_dispatch:
inputs:
tag_version:
description: "Tag version for release (e.g., 1.2.3)"
required: true
type: string
do_github_release:
description: "Perform a GitHub release?"
required: true
Expand Down Expand Up @@ -60,7 +64,6 @@ jobs:
name: macos-binary
path: out/aplang

# --- JOB: create-pkg ---
create-pkg:
name: Create MacOS `.pkg`
runs-on: macos-latest
Expand All @@ -75,18 +78,18 @@ jobs:
run: |
echo "$APPLICATION_CERT_BASE64" | base64 --decode > application_cert.p12
echo "$INSTALLER_CERT_BASE64" | base64 --decode > installer_cert.p12
# Create a temporary keychain with a temporary password
security create-keychain -p "$TEMP_KEYCHAIN_PASSWORD" temp.keychain
security unlock-keychain -p "$TEMP_KEYCHAIN_PASSWORD" temp.keychain
# Set temp.keychain as default keychain
security default-keychain -s temp.keychain
# Import certificates into the temporary keychain
security import application_cert.p12 -k temp.keychain -P "$CERT_PASSWORD" -T /usr/bin/codesign -T /usr/bin/productsign
security import installer_cert.p12 -k temp.keychain -P "$CERT_PASSWORD" -T /usr/bin/codesign -T/usr/bin/productsign
# Set the key partition list with explicit unlocking
security set-key-partition-list -S apple-tool:,apple: -s -k "$TEMP_KEYCHAIN_PASSWORD" temp.keychain
Expand All @@ -104,8 +107,11 @@ jobs:
run: |
mkdir -p package-root/
chmod +x package-root/aplang
TAG_VERSION="${GITHUB_REF_NAME#v}"
TAG_VERSION="${TAG_VERSION:-0.0.0}"
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
TAG_VERSION="${{ github.event.inputs.tag_version }}"
else
TAG_VERSION="${GITHUB_REF_NAME#v}"
fi
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV
- name: Sign Application Binary
Expand All @@ -119,17 +125,16 @@ jobs:
- name: Sign the package
run: |
productsign --keychain temp.keychain --sign "Developer ID Installer: Patrick Unick (423YZUTX3G)" aplang-unsigned.pkg aplang.pkg
# - name: Notarize the package
# env:
# APPLE_ID_EMAIL: ${{ secrets.APPLE_ID_EMAIL }}
# APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
# run: |
# # Submit notary
# xcrun notarytool submit aplang.pkg --apple-id "$APPLE_ID_EMAIL" --team-id "423YZUTX3G" --password "$APPLE_APP_SPECIFIC_PASSWORD" --wait
# # Staple the notary
# xcrun stapler staple aplang.pkg
- name: Notarize the package
env:
APPLE_ID_EMAIL: ${{ secrets.APPLE_ID_EMAIL }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
run: |
# Submit notary
xcrun notarytool submit aplang.pkg --apple-id "$APPLE_ID_EMAIL" --team-id "423YZUTX3G" --password "$APPLE_APP_SPECIFIC_PASSWORD" --wait
# Staple the notary
xcrun stapler staple aplang.pkg
- name: Upload `.pkg` Artifact
uses: actions/upload-artifact@v4
Expand All @@ -140,6 +145,8 @@ jobs:
build-msix:
runs-on: windows-latest
needs: build-windows
env:
INPUT_TAG_VERSION: ${{ github.event.inputs.tag_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -157,13 +164,14 @@ jobs:

- name: Update Package Version
run: |
if ($Env:GITHUB_REF_TYPE -eq "tag") {
if ($Env:GITHUB_EVENT_NAME -eq "workflow_dispatch") {
$TAG_VERSION = $Env:INPUT_TAG_VERSION
} elseif ($Env:GITHUB_REF_TYPE -eq "tag") {
$TAG_VERSION = $Env:GITHUB_REF_NAME -replace '^v', ''
} else {
Write-Output "Not a tag build. Defaulting version to 0.0.0"
$TAG_VERSION = "0.0.0"
}
# Add `.0` to the end of the version
$TAG_VERSION = "$TAG_VERSION.0"
Expand All @@ -188,7 +196,6 @@ jobs:
release:
name: Create GitHub Release
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.do_github_release == 'true') }}

runs-on: ubuntu-latest
needs: [ build-windows, build-macos, create-pkg ]
steps:
Expand Down Expand Up @@ -223,12 +230,10 @@ jobs:
artifacts/macos/aplang
artifacts/macos/aplang.pkg
cargo-publish:
name: Publish to Crates.io
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && github.event.inputs.do_crates_release == 'true') }}

steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -241,9 +246,12 @@ jobs:
field: package.version

- name: Ensure Cargo.toml version matches tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
TAG_VERSION="${{ github.event.inputs.tag_version }}"
else
TAG_VERSION="${GITHUB_REF_NAME#v}"
fi
CARGO_VERSION="${{ steps.cargo_toml_version.outputs.value }}"
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "Error: Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
Expand All @@ -253,5 +261,4 @@ jobs:
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# allow dirty is to make sure the Cargo.lock is always submited
run: cargo publish --allow-dirty

0 comments on commit 9a91e1a

Please # to comment.