Repository navigation
171 lines (153 loc) · 5.68 KB
/
Copy pathrelease.yml
File metadata and controls
171 lines (153 loc) · 5.68 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
name: Release
# Builds self-contained Studio binaries for Windows + macOS (x64 + arm64)
# on every tag matching v*.*.*, zips them, and attaches the zips to a
# GitHub Release.
#
# Usage:
# git tag v0.1.0
# git push --tags
#
# Outputs attached to the release:
# - OpenApparatusStudio-<version>-win-x64.zip (extract, run OpenApparatus.Studio.exe)
# - OpenApparatusStudio-<version>-osx-x64.zip (extract, double-click the .app bundle)
# - OpenApparatusStudio-<version>-osx-arm64.zip (extract, double-click the .app bundle)
#
# Builds are unsigned. Windows SmartScreen will warn on first run; macOS
# Gatekeeper will block until the user right-clicks the .app and chooses Open.
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Version (e.g. 0.1.0). Required for manual runs.'
required: true
type: string
permissions:
contents: write
env:
STUDIO_PROJECT: src/OpenApparatus.Studio/OpenApparatus.Studio.csproj
APP_NAME: OpenApparatusStudio
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
rid: win-x64
- os: macos-latest
rid: osx-x64
- os: macos-latest
rid: osx-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout studio
uses: actions/checkout@v4
with:
path: openapparatus-studio
# Studio's csproj references Core as a sibling ProjectReference. Until
# Core ships on NuGet we clone it next to the studio checkout.
- name: Checkout core (sibling)
uses: actions/checkout@v4
with:
repository: OpenApparatus/core
path: openapparatus-core
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Resolve version
id: version
shell: bash
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="${{ inputs.version }}"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Building version $VERSION for ${{ matrix.rid }}"
- name: Publish
shell: bash
working-directory: openapparatus-studio
run: |
dotnet publish "$STUDIO_PROJECT" \
-c Release \
-r ${{ matrix.rid }} \
--self-contained true \
-p:OpenApparatusCoreRepo="$GITHUB_WORKSPACE/openapparatus-core/" \
-o publish
# On macOS, wrap the published binary in a minimal .app bundle so
# Finder will launch it on double-click. Without the bundle users
# would have to invoke the binary from Terminal, which isn't the
# "extract and run" experience the rest of the package targets.
- name: Wrap macOS app bundle
if: runner.os == 'macOS'
shell: bash
working-directory: openapparatus-studio
run: |
BUNDLE="bundle/$APP_NAME.app"
mkdir -p "$BUNDLE/Contents/MacOS"
mkdir -p "$BUNDLE/Contents/Resources"
cp -R publish/* "$BUNDLE/Contents/MacOS/"
chmod +x "$BUNDLE/Contents/MacOS/OpenApparatus.Studio"
cat > "$BUNDLE/Contents/Info.plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key><string>OpenApparatus.Studio</string>
<key>CFBundleIdentifier</key><string>org.openapparatus.studio</string>
<key>CFBundleName</key><string>OpenApparatus Studio</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>${{ steps.version.outputs.version }}</string>
<key>CFBundleVersion</key><string>${{ steps.version.outputs.version }}</string>
<key>NSHighResolutionCapable</key><true/>
</dict>
</plist>
PLIST
- name: Zip (Windows)
if: runner.os == 'Windows'
shell: pwsh
working-directory: openapparatus-studio
run: |
$name = "$env:APP_NAME-${{ steps.version.outputs.version }}-${{ matrix.rid }}.zip"
New-Item -ItemType Directory -Force -Path releases | Out-Null
Compress-Archive -Path publish/* -DestinationPath "releases/$name"
- name: Zip (macOS)
if: runner.os == 'macOS'
shell: bash
working-directory: openapparatus-studio
run: |
NAME="$APP_NAME-${{ steps.version.outputs.version }}-${{ matrix.rid }}.zip"
mkdir -p releases
# `ditto` preserves the macOS-specific bundle metadata that `zip`
# can lose; produces a Finder-friendly archive.
(cd bundle && ditto -c -k --sequesterRsrc --keepParent "$APP_NAME.app" "../releases/$NAME")
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.rid }}
path: openapparatus-studio/releases/*.zip
if-no-files-found: error
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Flatten release files
run: |
mkdir -p release-files
find artifacts -name '*.zip' -exec cp {} release-files/ \;
ls -la release-files
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release-files/*
generate_release_notes: true