-
Notifications
You must be signed in to change notification settings - Fork 2
231 lines (196 loc) · 8.53 KB
/
Copy pathrelease.yml
File metadata and controls
231 lines (196 loc) · 8.53 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: Build and Release
on:
push:
branches:
- main
paths:
- 'Sources/SwiftMacPackage/main.swift'
- '.github/workflows/release.yml'
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
version-changed: ${{ steps.check-tag.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from main.swift
id: get-version
run: |
VERSION=$(grep 'let version = ' Sources/SwiftMacPackage/main.swift | sed 's/.*"\(.*\)".*/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Found version: $VERSION"
- name: Check if version tag exists
id: check-tag
run: |
VERSION="${{ steps.get-version.outputs.version }}"
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "Tag v$VERSION already exists"
else
echo "changed=true" >> $GITHUB_OUTPUT
echo "Tag v$VERSION does not exist - will create release"
fi
build-and-release:
needs: check-version
if: needs.check-version.outputs.version-changed == 'true'
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Swift
uses: swift-actions/setup-swift@v2
- name: Build for Apple Silicon (arm64)
run: |
echo "Building for Apple Silicon (arm64)..."
swift build --configuration release --arch arm64
mkdir -p build-artifacts/arm64
cp .build/release/swiftmac build-artifacts/arm64/
cp -r .build/release/ogg.framework build-artifacts/arm64/
cp -r .build/release/vorbis.framework build-artifacts/arm64/
echo "Saved arm64 build artifacts"
file build-artifacts/arm64/swiftmac
- name: Clean build directory
run: |
echo "Cleaning build directory..."
rm -rf .build
- name: Build for Intel (x86_64)
run: |
echo "Building for Intel (x86_64)..."
swift build --configuration release --arch x86_64
mkdir -p build-artifacts/x86_64
cp .build/release/swiftmac build-artifacts/x86_64/
cp -r .build/release/ogg.framework build-artifacts/x86_64/
cp -r .build/release/vorbis.framework build-artifacts/x86_64/
echo "Saved x86_64 build artifacts"
file build-artifacts/x86_64/swiftmac
- name: Create Universal Binary
run: |
echo "Creating universal binary..."
# Verify source binaries
echo "ARM64 binary:"
file build-artifacts/arm64/swiftmac
lipo -info build-artifacts/arm64/swiftmac
echo "x86_64 binary:"
file build-artifacts/x86_64/swiftmac
lipo -info build-artifacts/x86_64/swiftmac
# Create universal binary for swiftmac executable
lipo -create \
build-artifacts/arm64/swiftmac \
build-artifacts/x86_64/swiftmac \
-output swiftmac-universal
# Verify it's universal
echo "Universal binary:"
file swiftmac-universal
lipo -info swiftmac-universal
# Check framework architectures
mkdir -p universal-frameworks
echo ""
echo "Checking ogg.framework architectures..."
echo "ARM64 version:"
lipo -info build-artifacts/arm64/ogg.framework/ogg || true
echo "x86_64 version:"
lipo -info build-artifacts/x86_64/ogg.framework/ogg || true
# Handle ogg framework - check if architectures differ
ARM_OGG_ARCH=$(lipo -info build-artifacts/arm64/ogg.framework/ogg 2>&1 | grep -o 'arm64\|x86_64' | head -1)
X86_OGG_ARCH=$(lipo -info build-artifacts/x86_64/ogg.framework/ogg 2>&1 | grep -o 'arm64\|x86_64' | head -1)
if [ "$ARM_OGG_ARCH" = "$X86_OGG_ARCH" ]; then
echo "ogg.framework has same architecture in both builds, using as-is"
cp -r build-artifacts/arm64/ogg.framework universal-frameworks/
else
echo "Creating universal ogg.framework"
cp -r build-artifacts/arm64/ogg.framework universal-frameworks/
lipo -create \
build-artifacts/arm64/ogg.framework/ogg \
build-artifacts/x86_64/ogg.framework/ogg \
-output universal-frameworks/ogg.framework/ogg
fi
echo ""
echo "Checking vorbis.framework architectures..."
echo "ARM64 version:"
lipo -info build-artifacts/arm64/vorbis.framework/vorbis || true
echo "x86_64 version:"
lipo -info build-artifacts/x86_64/vorbis.framework/vorbis || true
# Handle vorbis framework - check if architectures differ
ARM_VORBIS_ARCH=$(lipo -info build-artifacts/arm64/vorbis.framework/vorbis 2>&1 | grep -o 'arm64\|x86_64' | head -1)
X86_VORBIS_ARCH=$(lipo -info build-artifacts/x86_64/vorbis.framework/vorbis 2>&1 | grep -o 'arm64\|x86_64' | head -1)
if [ "$ARM_VORBIS_ARCH" = "$X86_VORBIS_ARCH" ]; then
echo "vorbis.framework has same architecture in both builds, using as-is"
cp -r build-artifacts/arm64/vorbis.framework universal-frameworks/
else
echo "Creating universal vorbis.framework"
cp -r build-artifacts/arm64/vorbis.framework universal-frameworks/
lipo -create \
build-artifacts/arm64/vorbis.framework/vorbis \
build-artifacts/x86_64/vorbis.framework/vorbis \
-output universal-frameworks/vorbis.framework/vorbis
fi
# Verify final frameworks
echo ""
echo "Final framework architectures:"
lipo -info universal-frameworks/ogg.framework/ogg
lipo -info universal-frameworks/vorbis.framework/vorbis
- name: Create release archive
run: |
VERSION="${{ needs.check-version.outputs.version }}"
echo "Building swiftmac version $VERSION (Universal Binary)"
# Create release directory
mkdir -p swiftmac
# Copy universal binary and frameworks
cp swiftmac-universal swiftmac/swiftmac
cp -rf universal-frameworks/ogg.framework swiftmac/
cp -rf universal-frameworks/vorbis.framework swiftmac/
# Copy support files
cp swiftmac-voices.el swiftmac/
cp cloud-swiftmac swiftmac/
cp log-swiftmac swiftmac/
# Copy documentation
cp LICENSE swiftmac/
cp Readme.org swiftmac/
cp Readme.emacspeak.org swiftmac/
# Create tarball
tar -czf swiftmac-$VERSION.tar.gz swiftmac
echo "Release archive created: swiftmac-$VERSION.tar.gz"
ls -lh swiftmac-$VERSION.tar.gz
shell: bash
- name: Create Git tag
run: |
VERSION="${{ needs.check-version.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v$VERSION" -m "Release version $VERSION"
git push origin "v$VERSION"
- name: Extract changelog
id: changelog
run: |
VERSION="${{ needs.check-version.outputs.version }}"
# Get commits since last tag
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
CHANGES=$(git log --pretty=format:"- %s" -10)
else
CHANGES=$(git log --pretty=format:"- %s" ${LAST_TAG}..HEAD)
fi
# Save to file for multiline output
echo "$CHANGES" > CHANGELOG.txt
echo "Extracted changelog for release"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.check-version.outputs.version }}
name: SwiftMac ${{ needs.check-version.outputs.version }}
body_path: CHANGELOG.txt
files: |
swiftmac-${{ needs.check-version.outputs.version }}.tar.gz
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update latest release symlink
run: |
VERSION="${{ needs.check-version.outputs.version }}"
echo "Released SwiftMac version $VERSION"
echo "Download: https://github.com/robertmeta/swiftmac/releases/download/v$VERSION/swiftmac-$VERSION.tar.gz"