Merge pull request #73 from OpenIPC/layout-reorg #43
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release OpenIPC Config App | |
permissions: | |
contents: write | |
actions: read | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- 'release-v*' # Trigger for tags that start with 'v', e.g., v1.0.0, v2.1.3 | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-latest, windows-latest, ubuntu-latest] | |
arch: [x64, arm64] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Read Version from VERSION File | |
id: get_version | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
VERSION=${VERSION#release-v} # Remove "release-v" prefix | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "v$VERSION" > OpenIPC_Config/VERSION | |
shell: bash | |
- name: Restore dependencies | |
run: dotnet restore OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj | |
- name: Build project | |
run: dotnet build OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj --configuration Release | |
- name: Run Tests | |
if: matrix.os == 'ubuntu-latest' && matrix.arch == 'x64' | |
run: dotnet test OpenIPC_Config.Tests/OpenIPC_Config.Tests.csproj --configuration Release --logger "trx;LogFileName=test-results.trx" | |
- name: Publish Project | |
run: | | |
if [[ "${{ runner.os }}" == "Windows" ]]; then | |
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r win-x64 --self-contained | |
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r win-arm64 --self-contained | |
elif [[ "${{ runner.os }}" == "macOS" ]]; then | |
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r osx-x64 --self-contained | |
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r osx-arm64 --self-contained | |
else | |
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r linux-x64 --self-contained | |
dotnet publish OpenIPC_Config.Desktop/OpenIPC_Config.Desktop.csproj -c Release -r linux-arm64 --self-contained | |
fi | |
shell: bash | |
# Packaging macOS .app bundle | |
- name: Package macOS .app | |
if: matrix.os == 'macos-latest' | |
run: | | |
APP_NAME="OpenIPC_Config" | |
PUBLISH_DIR="./OpenIPC_Config.Desktop/bin/Release/net8.0/osx-${{ matrix.arch }}/publish" | |
APP_DIR="${APP_NAME}.app" | |
mkdir -p "${APP_DIR}/Contents/MacOS" | |
mkdir -p "${APP_DIR}/Contents/Resources" | |
cp -R "${PUBLISH_DIR}/"* "${APP_DIR}/Contents/MacOS/" | |
cp ./OpenIPC_Config/Assets/Icons/OpenIPC.icns "${APP_DIR}/Contents/Resources/${APP_NAME}.icns" | |
cat << EOF > "${APP_DIR}/Contents/Info.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>${APP_NAME}</string> | |
<key>CFBundleExecutable</key> | |
<string>${APP_NAME}.Desktop</string> | |
<key>CFBundleIdentifier</key> | |
<string>com.openipc.${APP_NAME}</string> | |
<key>CFBundleVersion</key> | |
<string>${{ env.VERSION }}</string> | |
<key>CFBundlePackageType</key> | |
<string>APPL</string> | |
<key>LSMinimumSystemVersion</key> | |
<string>10.13</string> | |
<key>CFBundleIconFile</key> | |
<string>${APP_NAME}.icns</string> | |
</dict> | |
</plist> | |
EOF | |
chmod +x "${APP_DIR}/Contents/MacOS/${APP_NAME}.Desktop" | |
- name: Decode signing certificate | |
if: matrix.os == 'macos-latest' | |
env: | |
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} | |
run: | | |
echo "$APPLE_CERTIFICATE" | base64 --decode > macos_signing_cert.p12 | |
echo "$MACOS_PROVISION_PROFILE" | base64 --decode > macos_provision_profile.mobileprovision | |
- name: Create and manage custom keychain | |
if: matrix.os == 'macos-latest' | |
env: | |
MY_KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | |
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | |
run: | | |
echo "Creating custom keychain" | |
security create-keychain -p $MY_KEYCHAIN_PASSWORD build.keychain | |
echo "Importing signing certificate" | |
security import macos_signing_cert.p12 -k build.keychain -P $APPLE_CERTIFICATE_PASSWORD -T /usr/bin/codesign | |
echo "Unlocking keychain" | |
security unlock-keychain -p $MY_KEYCHAIN_PASSWORD build.keychain | |
echo "Setting key partition list" | |
security set-key-partition-list -S apple-tool:,apple: -s -k $MY_KEYCHAIN_PASSWORD build.keychain | |
- name: Use the custom keychain for signing | |
if: matrix.os == 'macos-latest' | |
run: | | |
security list-keychains -d user -s build.keychain-db | |
security find-identity | |
echo "Using custom keychain for codesign" | |
codesign --deep --force --verify --verbose --sign "Developer ID Application: Mike Carr (EQKLR945TW)" ./OpenIPC_Config.app | |
- name: Verify the signature | |
if: matrix.os == 'macos-latest' | |
run: | | |
codesign --verify --verbose=4 ./OpenIPC_Config.app | |
spctl --assess --type execute --verbose ./OpenIPC_Config.app | |
- name: Cleanup custom keychain | |
if: matrix.os == 'macos-latest' | |
run: | | |
echo "Cleaning up the custom keychain" | |
security delete-keychain build.keychain || true | |
# Linux Icon and Packaging | |
- name: Set up Icon and .desktop file | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
APP_NAME="OpenIPC-Config" | |
PUBLISH_DIR="./OpenIPC_Config.Desktop/bin/Release/net8.0/linux-x64/publish" | |
ICON_PATH="${PUBLISH_DIR}/Assets/OpenIPC.png" | |
DESKTOP_FILE="${PUBLISH_DIR}/${APP_NAME}.desktop" | |
# Ensure the icon is in the publish directory | |
cp ./OpenIPC_Config/Assets/Icons/OpenIPC.png "$ICON_PATH" | |
# Create .desktop file | |
cat << EOF > "$DESKTOP_FILE" | |
[Desktop Entry] | |
Name=OpenIPC Config | |
Exec=$PUBLISH_DIR/OpenIPC-Config.Desktop | |
Icon=$ICON_PATH | |
Type=Application | |
Terminal=false | |
Categories=Utility; | |
EOF | |
# Windows Icon and Packaging | |
- name: Set Windows Icon and Package | |
if: matrix.os == 'windows-latest' | |
shell: pwsh | |
run: | | |
$PUBLISH_DIR = "./OpenIPC_Config.Desktop/bin/Release/net8.0/win-${{ matrix.arch }}/publish" | |
$ICON_PATH = "./OpenIPC_Config/Assets/Icons/OpenIPC.ico" | |
# Install rcedit to modify the Windows executable icon | |
choco install rcedit -y | |
rcedit "$PUBLISH_DIR/OpenIPC_Config.Desktop.exe" --set-icon "$ICON_PATH" | |
# Zip the Windows build | |
Compress-Archive -Path "$PUBLISH_DIR\*" -DestinationPath "OpenIPC-Config-windows-${{ matrix.arch }}.zip" | |
env: | |
DOTNET_ROOT: C:\Program Files\dotnet | |
VERSION: 0.0.1 | |
- name: Zip .app Bundle for MacOS and Linux | |
run: | | |
echo "Runner OS: ${{ runner.os }}" | |
if [[ "${{ runner.os }}" == "macOS" ]]; then | |
DMG_NAME="OpenIPC-Config-macos-${{ matrix.arch }}.dmg" | |
APP_NAME="OpenIPC_Config.app" | |
BUILD_DIR="OpenIPC-Config-macos-${{ matrix.arch }}-dmg-build" | |
# Create a temporary folder for the .dmg contents | |
mkdir -p "${BUILD_DIR}" | |
cp -R "${APP_NAME}" "${BUILD_DIR}/" | |
# Create an alias to the Applications folder | |
ln -s /Applications "${BUILD_DIR}/Applications" | |
# Create the .dmg with the Applications alias | |
hdiutil create -volname "OpenIPC Config" -srcfolder "${BUILD_DIR}" -ov -format UDZO "${DMG_NAME}" | |
# Clean up the temporary build folder | |
rm -rf "${BUILD_DIR}" | |
elif [[ "${{ runner.os }}" == "Linux" ]]; then | |
mkdir -p OpenIPC-Config-linux-${{ matrix.arch }} | |
cp -r ./OpenIPC_Config.Desktop/bin/Release/net8.0/linux-${{ matrix.arch }}/publish/* OpenIPC-Config-linux-${{ matrix.arch }}/ | |
zip -r OpenIPC-Config-linux-${{ matrix.arch }}.zip OpenIPC-Config-linux-${{ matrix.arch }} | |
echo "directory created" | |
ls -al | |
# zip -r OpenIPC-Config-linux-${{ matrix.arch }}.zip ./OpenIPC_Config.Desktop/bin/Release/net8.0/linux-${{ matrix.arch }}/publish/* | |
fi | |
shell: bash | |
# Upload Artifacts | |
- name: Upload macOS Artifact | |
if: matrix.os == 'macos-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: OpenIPC-Config-macos-${{ matrix.arch }}.dmg | |
path: OpenIPC-Config-macos-${{ matrix.arch }}.dmg | |
- name: Upload Windows Artifact | |
if: matrix.os == 'windows-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: OpenIPC-Config-windows-${{ matrix.arch }} | |
path: OpenIPC-Config-windows-${{ matrix.arch }}.zip | |
- name: Upload Ubuntu Artifact | |
if: matrix.os == 'ubuntu-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: OpenIPC-Config-linux-${{ matrix.arch }} | |
path: OpenIPC-Config-linux-${{ matrix.arch }}.zip | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Read Version from VERSION File | |
id: get_version | |
run: | | |
#VERSION=$(cat VERSION) | |
VERSION=${GITHUB_REF#refs/tags/} | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
shell: bash | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: . | |
- name: List Downloaded Files | |
run: ls -R . | |
- name: Generate latest.json | |
run: | | |
cat << EOF > latest.json | |
{ | |
"version": "${{ env.VERSION }}", | |
"release_notes": "This is a dynamically generated release note. Update as needed.", | |
"download_url": "https://github.com/${{ github.repository }}/releases/" | |
} | |
EOF | |
- name: Create GitHub Release and Upload Assets | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
draft: true | |
generate_release_notes: true | |
files: | | |
./OpenIPC-Config-*/OpenIPC-Config-*.zip | |
./OpenIPC-Config-*/OpenIPC-Config-*.dmg | |
./latest.json |