Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
name: Release

# A version tag (v0.1.0) builds the Windows MSI and the macOS .dmg files and publishes them as a
# GitHub release. A pull request that changes the packaging, or a run by hand, builds the same
# installers as workflow artifacts only, so packaging is proven before anything is tagged.
on:
push:
tags: ['v*']
pull_request:
paths:
- 'packaging/**'
- '.github/workflows/release.yml'
workflow_dispatch:

# Read-only by default; only the release job escalates to contents: write.
permissions:
contents: read

env:
PUBLISH_FLAGS: >-
-c Release --self-contained true
-p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
-p:DebugType=none -p:DebugSymbols=false

jobs:
version:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
version: ${{ steps.v.outputs.version }}
msi_version: ${{ steps.v.outputs.msi_version }}
prerelease: ${{ steps.v.outputs.prerelease }}
steps:
# Tag push: the tag without its "v". Otherwise a dev version that never collides with a tag.
# WiX accepts only a numeric ProductVersion, so the MSI carries the numeric core.
- id: v
env:
EVENT: ${{ github.event_name }}
REF_NAME: ${{ github.ref_name }}
RUN_NUMBER: ${{ github.run_number }}
run: |
if [ "$EVENT" = "push" ]; then
version="${REF_NAME#v}"
else
version="0.0.0-dev.${RUN_NUMBER}"
fi
if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$'; then
echo "::error::Not a version: $version"
exit 1
fi
core="${version%%-*}"
prerelease=false
[ "$version" != "$core" ] && prerelease=true
{
echo "version=$version"
echo "msi_version=$core"
echo "prerelease=$prerelease"
} >> "$GITHUB_OUTPUT"

windows:
needs: version
runs-on: windows-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: '10.0.x'

- name: Publish
shell: pwsh
env:
VERSION: ${{ needs.version.outputs.version }}
run: >
dotnet publish src/Freizeichen.App/Freizeichen.App.csproj -r win-x64 ${{ env.PUBLISH_FLAGS }}
"-p:Version=$env:VERSION" -o publish

# The GITHUB_PATH write appends a fixed directory, nothing derived from input.
- name: Install WiX
shell: pwsh
run: | # zizmor: ignore[github-env]
dotnet tool install --global wix --version 5.0.2
echo "$env:USERPROFILE\.dotnet\tools" >> $env:GITHUB_PATH

# Absolute PublishDir: WiX resolves <Files Include> relative to the .wxs file's directory.
# -arch x64: WiX defaults to x86, which would install into "Program Files (x86)".
- name: Build MSI
shell: pwsh
env:
VERSION: ${{ needs.version.outputs.version }}
MSI_VERSION: ${{ needs.version.outputs.msi_version }}
run: >
wix build packaging/windows/Freizeichen.wxs -arch x64
-d "Version=$env:MSI_VERSION"
-d "PublishDir=$env:GITHUB_WORKSPACE\publish"
-o "freizeichen-$env:VERSION-windows-x64.msi"

- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: windows
path: '*.msi'
if-no-files-found: error

macos:
needs: version
strategy:
fail-fast: false
matrix:
include:
- rid: osx-arm64
arch: arm64
- rid: osx-x64
arch: x64
runs-on: macos-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: '10.0.x'

- name: Publish
env:
VERSION: ${{ needs.version.outputs.version }}
RID: ${{ matrix.rid }}
run: >
dotnet publish src/Freizeichen.App/Freizeichen.App.csproj -r "$RID" ${{ env.PUBLISH_FLAGS }}
"-p:Version=${VERSION}" -o publish

- name: Build .dmg
env:
VERSION: ${{ needs.version.outputs.version }}
ARCH: ${{ matrix.arch }}
run: packaging/macos/build-dmg.sh "$VERSION" publish "$ARCH" dist

- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: macos-${{ matrix.arch }}
path: dist/*.dmg
if-no-files-found: error

release:
if: github.event_name == 'push'
needs: [version, windows, macos]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write # create the release and upload its assets
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: dist
merge-multiple: true

- name: Checksums
working-directory: dist
run: sha256sum -- * > SHA256SUMS.txt

- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
VERSION: ${{ needs.version.outputs.version }}
PRERELEASE: ${{ needs.version.outputs.prerelease }}
run: |
cat > notes.md <<NOTES
Freizeichen ${VERSION} – wählt \`tel:\`-Links über ein Gigaset DL500A per Bluetooth.

**Installation**
- **Windows**: \`freizeichen-${VERSION}-windows-x64.msi\` ausführen. Danach Freizeichen starten, den Bluetooth-Port wählen und „Als Standard festlegen“ drücken.
- **macOS**: Die passende \`.dmg\` öffnen (\`arm64\` für Apple-Chips, \`x64\` für Intel) und Freizeichen in „Programme“ ziehen.

**Die Pakete sind nicht signiert.** Beim ersten Start:
- **Windows**: SmartScreen → „Weitere Informationen“ → „Trotzdem ausführen“.
- **macOS**: Rechtsklick auf Freizeichen.app → „Öffnen“ (einmalig bestätigen).

**Prüfsummen**: \`SHA256SUMS.txt\` – \`sha256sum -c SHA256SUMS.txt\` (Linux) bzw. \`shasum -a 256 -c SHA256SUMS.txt\` (macOS).
NOTES
flags=()
[ "$PRERELEASE" = "true" ] && flags+=(--prerelease)
gh release create "$TAG" dist/* --repo "$REPO" --title "Freizeichen ${VERSION}" --notes-file notes.md "${flags[@]}"
60 changes: 60 additions & 0 deletions packaging/macos/build-dmg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# Build an unsigned Freizeichen.app and wrap it in a drag-to-Applications .dmg. macOS-only
# (hdiutil, codesign). Runs on the macos-latest CI runner.
#
# build-dmg.sh <version> <publish-dir> <arch> <out-dir>
set -euo pipefail

VERSION="$1"
PUBLISH_DIR="$2"
ARCH="$3"
OUT_DIR="$4"

APP="Freizeichen.app"
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT

APP_DIR="$STAGE/$APP"
install -d "$APP_DIR/Contents/MacOS" "$APP_DIR/Contents/Resources"

cp -R "$PUBLISH_DIR"/. "$APP_DIR/Contents/MacOS/"
chmod +x "$APP_DIR/Contents/MacOS/Freizeichen"

# CFBundleURLTypes is what lets Launch Services hand tel: links to the app; it delivers them as an
# Apple event, not an argument. The bundle id must match MacTelHandlerRegistration.BundleId.
cat > "$APP_DIR/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>CFBundleName</key> <string>Freizeichen</string>
<key>CFBundleDisplayName</key> <string>Freizeichen</string>
<key>CFBundleIdentifier</key> <string>io.github.deepdiver1975.freizeichen</string>
<key>CFBundleVersion</key> <string>$VERSION</string>
<key>CFBundleShortVersionString</key><string>$VERSION</string>
<key>CFBundleExecutable</key> <string>Freizeichen</string>
<key>CFBundlePackageType</key> <string>APPL</string>
<key>LSMinimumSystemVersion</key> <string>12.0</string>
<key>NSHighResolutionCapable</key> <true/>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Freizeichen wählt über die serielle Bluetooth-Schnittstelle des Telefons.</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key> <string>Telefonnummer</string>
<key>CFBundleURLSchemes</key> <array><string>tel</string></array>
</dict>
</array>
</dict>
</plist>
PLIST

# No Developer ID, so sign with the ad-hoc identity "-": without any signature Gatekeeper reports
# the app as damaged instead of offering to open it.
codesign --force --deep --sign - "$APP_DIR"

ln -s /Applications "$STAGE/Applications"
mkdir -p "$OUT_DIR"
DMG="$OUT_DIR/freizeichen-${VERSION}-macos-${ARCH}.dmg"
hdiutil create -volname "Freizeichen" -srcfolder "$STAGE" -ov -format UDZO "$DMG" 1>&2
echo "$DMG"
66 changes: 66 additions & 0 deletions packaging/windows/Freizeichen.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
WiX v5 authoring for the Freizeichen MSI. Built by .github/workflows/release.yml with:
wix build packaging/windows/Freizeichen.wxs -arch x64 -d Version=<v> -d PublishDir=<dir> -o out.msi

The UpgradeCode is fixed forever: it is what lets a new version replace the old one instead of
installing side by side.
-->
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="Freizeichen"
Manufacturer="CodeForFire"
Version="$(Version)"
UpgradeCode="e2d3daf5-0643-4aa8-b45a-fc1de3e0eef3"
Scope="perMachine"
Compressed="yes">

<MajorUpgrade AllowSameVersionUpgrades="yes"
DowngradeErrorMessage="Eine neuere Version von Freizeichen ist bereits installiert." />

<MediaTemplate EmbedCab="yes" />

<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="Freizeichen" />
</StandardDirectory>

<StandardDirectory Id="ProgramMenuFolder" />

<Feature Id="Main">
<Files Include="$(PublishDir)\**" Directory="INSTALLFOLDER" />
<ComponentRef Id="StartMenuShortcut" />
<ComponentRef Id="TelCapability" />
</Feature>

<!-- A shortcut component needs its own keypath, hence the HKCU value. -->
<Component Id="StartMenuShortcut" Directory="ProgramMenuFolder" Guid="*">
<Shortcut Id="FreizeichenShortcut"
Name="Freizeichen"
Description="tel:-Links über ein Gigaset-Telefon wählen"
Target="[INSTALLFOLDER]Freizeichen.exe"
WorkingDirectory="INSTALLFOLDER" />
<RegistryValue Root="HKCU" Key="Software\Freizeichen"
Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>

<!--
Registers Freizeichen as *capable* of opening tel: links. Windows lets no installer make itself
the default; the user picks it once under Default apps, which the settings window opens.
The names must match WindowsTelHandlerRegistration: ProgId "Freizeichen.tel" and the
RegisteredApplications value "Freizeichen".
-->
<Component Id="TelCapability" Directory="INSTALLFOLDER" Guid="*">
<RegistryValue Root="HKLM" Key="Software\Classes\Freizeichen.tel"
Value="Freizeichen tel:-Link" Type="string" KeyPath="yes" />
<RegistryValue Root="HKLM" Key="Software\Classes\Freizeichen.tel\shell\open\command"
Value="&quot;[INSTALLFOLDER]Freizeichen.exe&quot; &quot;%1&quot;" Type="string" />
<RegistryValue Root="HKLM" Key="Software\Freizeichen\Capabilities"
Name="ApplicationName" Value="Freizeichen" Type="string" />
<RegistryValue Root="HKLM" Key="Software\Freizeichen\Capabilities"
Name="ApplicationDescription" Value="Wählt tel:-Links über ein Gigaset-Telefon per Bluetooth." Type="string" />
<RegistryValue Root="HKLM" Key="Software\Freizeichen\Capabilities\URLAssociations"
Name="tel" Value="Freizeichen.tel" Type="string" />
<RegistryValue Root="HKLM" Key="Software\RegisteredApplications"
Name="Freizeichen" Value="Software\Freizeichen\Capabilities" Type="string" />
</Component>
</Package>
</Wix>
Loading