mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-02-18 00:17:40 +01:00
230 lines
7.3 KiB
YAML
230 lines
7.3 KiB
YAML
name: "Build"
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- '.github/workflows/**'
|
|
- 'lib/**'
|
|
- 'accessibility/**'
|
|
- 'keypress_simulator/**'
|
|
- 'pubspec.yaml'
|
|
|
|
jobs:
|
|
build:
|
|
name: Build & Release
|
|
runs-on: macos-latest
|
|
|
|
permissions:
|
|
id-token: write
|
|
pages: write
|
|
contents: write
|
|
|
|
steps:
|
|
#1 Checkout Repository
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install certificates
|
|
env:
|
|
DEVELOPER_ID_APPLICATION_P12_BASE64_MAC: ${{ secrets.DEVELOPER_ID_APPLICATION_P12_BASE64_MAC }}
|
|
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
|
|
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
|
run: |
|
|
# create variables
|
|
DEVELOPER_ID_APPLICATION_CERTIFICATE_PATH=$RUNNER_TEMP/build_developerID_application_certificate.p12
|
|
KEYCHAIN_PATH=$RUNNER_TEMP/pg-signing.keychain-db
|
|
|
|
# import certificate and provisioning profile from secrets
|
|
echo -n "$DEVELOPER_ID_APPLICATION_P12_BASE64_MAC" | base64 --decode --output $DEVELOPER_ID_APPLICATION_CERTIFICATE_PATH
|
|
|
|
# create temporary keychain
|
|
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
|
# security default-keychain -s $KEYCHAIN_PATH
|
|
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
|
|
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
|
|
|
# import certificate to keychain
|
|
security import $DEVELOPER_ID_APPLICATION_CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
|
|
security list-keychain -d user -s $KEYCHAIN_PATH
|
|
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
|
|
|
#2 Setup Java
|
|
- name: Set Up Java
|
|
uses: actions/setup-java@v3.12.0
|
|
with:
|
|
distribution: 'oracle'
|
|
java-version: '17'
|
|
|
|
#3 Setup Flutter
|
|
- name: Set Up Flutter
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
channel: 'stable'
|
|
|
|
#4 Install Dependencies
|
|
- name: Install Dependencies
|
|
run: flutter pub get
|
|
|
|
#8 Build app ( macos Build )
|
|
- name: Build App
|
|
run: flutter build macos --release
|
|
|
|
- name: Code Signing
|
|
run: /usr/bin/codesign --deep --force -s "$DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY" --options runtime SwiftControl.app -v
|
|
working-directory: build/macos/Build/Products/Release
|
|
env:
|
|
DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY: ${{ secrets.DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY }}
|
|
|
|
- name: Decode Keystore
|
|
run: |
|
|
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/android.keystore;
|
|
echo "${{ secrets.KEYSTORE_PROPERTIES }}" > android/keystore.properties;
|
|
|
|
#6 Building APK
|
|
- name: Build APK
|
|
run: flutter build apk --release
|
|
|
|
- name: Build Web
|
|
run: flutter build web --release --base-href "/swiftcontrol/"
|
|
|
|
- name: Handle archives
|
|
run: |
|
|
cp build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/SwiftControl.android.apk
|
|
cd build/macos/Build/Products/Release/
|
|
zip -r SwiftControl.macos.zip SwiftControl.app/
|
|
|
|
#9 Upload Artifacts
|
|
- name: Upload Artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: Releases
|
|
path: |
|
|
build/app/outputs/flutter-apk/SwiftControl.android.apk
|
|
build/macos/Build/Products/Release/SwiftControl.macos.zip
|
|
|
|
#10 Extract Version
|
|
- name: Extract version from pubspec.yaml
|
|
id: extract_version
|
|
run: |
|
|
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
|
|
echo "VERSION=$version" >> $GITHUB_ENV
|
|
|
|
#11 Check if Tag Exists
|
|
- name: Check if Tag Exists
|
|
id: check_tag
|
|
run: |
|
|
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
|
|
echo "TAG_EXISTS=true" >> $GITHUB_ENV
|
|
else
|
|
echo "TAG_EXISTS=false" >> $GITHUB_ENV
|
|
fi
|
|
|
|
#12 Modify Tag if it Exists
|
|
- name: Modify Tag
|
|
if: env.TAG_EXISTS == 'true'
|
|
id: modify_tag
|
|
run: |
|
|
new_version="${{ env.VERSION }}-build-${{ github.run_number }}"
|
|
echo "VERSION=$new_version" >> $GITHUB_ENV
|
|
|
|
#13 Create Release
|
|
- name: Create Release
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
artifacts: "build/app/outputs/flutter-apk/SwiftControl.android.apk,build/macos/Build/Products/Release/SwiftControl.macos.zip"
|
|
tag: v${{ env.VERSION }}
|
|
token: ${{ secrets.TOKEN }}
|
|
|
|
- name: Upload static files as artifact
|
|
id: deployment
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: build/web
|
|
|
|
- name: Web Deploy
|
|
uses: actions/deploy-pages@v4
|
|
|
|
windows:
|
|
needs: build
|
|
name: Build & Release on Windows
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
#1 Checkout Repository
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v3
|
|
|
|
#2 Setup Java
|
|
- name: Set Up Java
|
|
uses: actions/setup-java@v3.12.0
|
|
with:
|
|
distribution: 'oracle'
|
|
java-version: '17'
|
|
|
|
#3 Setup Flutter
|
|
- name: Set Up Flutter
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
channel: 'stable'
|
|
|
|
#4 Install Dependencies
|
|
- name: Install Dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Build App
|
|
run: flutter build windows
|
|
|
|
- name: Zip directory (Windows)
|
|
shell: pwsh
|
|
run: |
|
|
|
|
$source = "C:\Windows\System32"
|
|
$destination = "build\windows\x64\runner\Release"
|
|
|
|
# List of required DLLs
|
|
$dlls = @("msvcp140.dll", "vcruntime140.dll", "vcruntime140_1.dll")
|
|
|
|
# Copy each file
|
|
foreach ($dll in $dlls) {
|
|
$srcPath = Join-Path $source $dll
|
|
$destPath = Join-Path $destination $dll
|
|
|
|
if (Test-Path $srcPath) {
|
|
Copy-Item -Path $srcPath -Destination $destPath -Force
|
|
Write-Output "Copied $dll to $destination"
|
|
} else {
|
|
Write-Warning "$dll not found in $source"
|
|
}
|
|
}
|
|
Compress-Archive -Path "build/windows/x64/runner/Release/*" -DestinationPath "build/windows/x64/runner/Release/SwiftControl.windows.zip"
|
|
|
|
#9 Upload Artifacts
|
|
- name: Upload Artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
overwrite: true
|
|
name: Releases
|
|
path: |
|
|
build/windows/x64/runner/Release/SwiftControl.windows.zip
|
|
|
|
#10 Extract Version
|
|
- name: Extract version from pubspec.yaml (Windows)
|
|
shell: pwsh
|
|
run: |
|
|
$version = Select-String '^version: ' pubspec.yaml | ForEach-Object {
|
|
($_ -split ' ')[1].Trim()
|
|
}
|
|
echo "VERSION=$version" >> $env:GITHUB_ENV
|
|
|
|
# add artifact to release
|
|
|
|
- name: Create Release
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
allowUpdates: true
|
|
artifacts: "build/windows/x64/runner/Release/SwiftControl.windows.zip"
|
|
tag: v${{ env.VERSION }}
|
|
token: ${{ secrets.TOKEN }}
|