-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (98 loc) · 4.07 KB
/
Copy pathspm_release.yml
File metadata and controls
113 lines (98 loc) · 4.07 KB
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
# Prebuilds FontManager.xcframework, publishes it as a GitHub release, and
# stamps the URL + checksum into Package.swift and nativescript.config.ts.
#
# On success it dispatches the npm Release workflow, which publishes
# @nativescript/font-manager from the tag it created.
name: SPM Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. 1.0.12). Defaults to packages/font-manager/package.json.'
required: false
type: string
permissions:
contents: write
actions: write # dispatch npm_release.yml
concurrency:
group: spm-release
cancel-in-progress: false
env:
XCODE_VERSION: '^26.0'
jobs:
release:
runs-on: macos-26
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Resolve version
id: version
run: |
VERSION="${{ github.event.inputs.version }}"
if [ -z "$VERSION" ]; then
VERSION="$(node -p "require('./packages/font-manager/package.json').version")"
fi
if git ls-remote --exit-code --tags origin "refs/tags/$VERSION" > /dev/null; then
echo "error: tag $VERSION already exists" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Install visionOS platform
run: |
xcodebuild -version
sudo xcodebuild -runFirstLaunch
if ! xcodebuild -showsdks | grep -q xros; then
sudo xcodebuild -downloadPlatform visionOS
fi
- name: Build FontManager.xcframework
run: ./tools/scripts/build-xcframework.sh "$PWD/dist/spm"
- name: Stamp Package.swift and nativescript.config.ts
run: node tools/scripts/stamp-spm-release.mjs "${{ steps.version.outputs.version }}" "$(cat dist/spm/FontManager.xcframework.zip.checksum)"
- name: Stamp package.json version
working-directory: packages/font-manager
run: npm version "${{ steps.version.outputs.version }}" --no-git-tag-version --allow-same-version
- name: Commit and tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Package.swift packages/font-manager/nativescript.config.ts packages/font-manager/package.json
git commit -m "release: FontManager.xcframework ${{ steps.version.outputs.version }}"
git pull --rebase origin main
git tag "${{ steps.version.outputs.version }}"
git push origin HEAD:main "refs/tags/${{ steps.version.outputs.version }}"
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.version.outputs.version }}" \
dist/spm/FontManager.xcframework.zip \
--title "${{ steps.version.outputs.version }}" \
--notes "FontManager.xcframework checksum: \`$(cat dist/spm/FontManager.xcframework.zip.checksum)\`"
- name: Verify SPM resolution
run: |
VERSION="${{ steps.version.outputs.version }}"
mkdir -p /tmp/spm-verify/Sources/Verify
echo > /tmp/spm-verify/Sources/Verify/Verify.swift
cat > /tmp/spm-verify/Package.swift <<EOF
// swift-tools-version: 5.10
import PackageDescription
let package = Package(
name: "Verify",
platforms: [.iOS(.v13)],
dependencies: [
.package(url: "https://github.com/${{ github.repository }}.git", exact: "$VERSION")
],
targets: [
.target(name: "Verify", dependencies: [.product(name: "FontManager", package: "font-manager")])
]
)
EOF
cd /tmp/spm-verify && swift package resolve
- name: Trigger npm release
env:
GH_TOKEN: ${{ github.token }}
run: gh workflow run npm_release.yml --ref main -f version="${{ steps.version.outputs.version }}"