diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e0d972c --- /dev/null +++ b/.github/workflows/release.yml @@ -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 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 < +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" < + + + + CFBundleName Freizeichen + CFBundleDisplayName Freizeichen + CFBundleIdentifier io.github.deepdiver1975.freizeichen + CFBundleVersion $VERSION + CFBundleShortVersionString$VERSION + CFBundleExecutable Freizeichen + CFBundlePackageType APPL + LSMinimumSystemVersion 12.0 + NSHighResolutionCapable + NSBluetoothAlwaysUsageDescription + Freizeichen wählt über die serielle Bluetooth-Schnittstelle des Telefons. + CFBundleURLTypes + + + CFBundleURLName Telefonnummer + CFBundleURLSchemes tel + + + + +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" diff --git a/packaging/windows/Freizeichen.wxs b/packaging/windows/Freizeichen.wxs new file mode 100644 index 0000000..ca228e2 --- /dev/null +++ b/packaging/windows/Freizeichen.wxs @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +