Fix/actions (#4) #13
Workflow file for this run
This file contains hidden or 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: Release | |
| on: | |
| push: | |
| # tags: | |
| # - "v*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| UI_BIN_NAME: rustickers | |
| CLI_BIN_NAME: rusticker | |
| MACOS_APP_NAME: Rustickers | |
| jobs: | |
| build-and-upload: | |
| name: Build (${{ matrix.artifact_suffix }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact_suffix: windows-x86_64 | |
| binary_ext: ".exe" | |
| artifact_ext: ".zip" | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| artifact_suffix: linux-x86_64 | |
| binary_ext: "" | |
| artifact_ext: ".tar.gz" | |
| - os: macos-14 | |
| target: aarch64-apple-darwin | |
| artifact_suffix: macos-aarch64 | |
| binary_ext: "" | |
| artifact_ext: ".zip" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: release-${{ matrix.target }} | |
| - name: Install Linux build dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| if apt-cache show libwebkit2gtk-4.1-dev >/dev/null 2>&1; then | |
| WEBKIT_DEV=libwebkit2gtk-4.1-dev | |
| JSCORE_DEV=libjavascriptcoregtk-4.1-dev | |
| else | |
| WEBKIT_DEV=libwebkit2gtk-4.0-dev | |
| JSCORE_DEV=libjavascriptcoregtk-4.0-dev | |
| fi | |
| sudo apt-get install -y --no-install-recommends \ | |
| zip \ | |
| pkg-config \ | |
| libglib2.0-dev \ | |
| libgtk-3-dev \ | |
| libasound2-dev \ | |
| "$WEBKIT_DEV" \ | |
| "$JSCORE_DEV" \ | |
| libx11-dev \ | |
| libxcursor-dev \ | |
| libxrandr-dev \ | |
| libxi-dev \ | |
| libxkbcommon-dev \ | |
| libwayland-dev \ | |
| libfontconfig1-dev \ | |
| libfreetype6-dev \ | |
| libegl1-mesa-dev \ | |
| libgl1-mesa-dev | |
| - name: Build (release) | |
| run: | | |
| cargo build --release --locked --target ${{ matrix.target }} --bin ${{ env.UI_BIN_NAME }} | |
| cargo build --release --locked --target ${{ matrix.target }} --bin ${{ env.CLI_BIN_NAME }} --no-default-features --features cli | |
| - name: Package (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| $safeRef = ($env:GITHUB_REF_NAME -replace '[\\/:*?"<>|]', '-') | |
| $uiArtifact = "${env:UI_BIN_NAME}-${safeRef}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}" | |
| $cliArtifact = "${env:CLI_BIN_NAME}-${safeRef}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}" | |
| $uiBin = "${env:UI_BIN_NAME}${{ matrix.binary_ext }}" | |
| $uiSrc = "target\${{ matrix.target }}\release\$uiBin" | |
| if (-not (Test-Path $uiSrc)) { | |
| throw "UI binary not found at $uiSrc" | |
| } | |
| $cliBin = "${env:CLI_BIN_NAME}${{ matrix.binary_ext }}" | |
| $cliSrc = "target\${{ matrix.target }}\release\$cliBin" | |
| if (-not (Test-Path $cliSrc)) { | |
| throw "CLI binary not found at $cliSrc" | |
| } | |
| New-Item -ItemType Directory -Force -Path dist-ui | Out-Null | |
| Copy-Item $uiSrc -Destination dist-ui\ -Force | |
| New-Item -ItemType Directory -Force -Path dist-cli | Out-Null | |
| Copy-Item $cliSrc -Destination dist-cli\ -Force | |
| # Include common docs if present | |
| Get-ChildItem -Path . -Filter "README*" -File -ErrorAction SilentlyContinue | ForEach-Object { | |
| Copy-Item $_.FullName -Destination dist-ui\ -Force | |
| Copy-Item $_.FullName -Destination dist-cli\ -Force | |
| } | |
| if (Test-Path "LICENSE") { | |
| Copy-Item "LICENSE" -Destination dist-ui\ -Force | |
| Copy-Item "LICENSE" -Destination dist-cli\ -Force | |
| } | |
| if (Test-Path $uiArtifact) { Remove-Item $uiArtifact -Force } | |
| Compress-Archive -Path "dist-ui\*" -DestinationPath $uiArtifact -Force | |
| if (Test-Path $cliArtifact) { Remove-Item $cliArtifact -Force } | |
| Compress-Archive -Path "dist-cli\*" -DestinationPath $cliArtifact -Force | |
| - name: Package (Linux) | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| safe_ref="$(echo "$GITHUB_REF_NAME" | tr '/\\:*?"<>|' '-')" | |
| ui_src="target/${{ matrix.target }}/release/${UI_BIN_NAME}" | |
| if [[ ! -f "$ui_src" ]]; then | |
| echo "UI binary not found at $ui_src" >&2 | |
| exit 1 | |
| fi | |
| cli_src="target/${{ matrix.target }}/release/${CLI_BIN_NAME}" | |
| if [[ ! -f "$cli_src" ]]; then | |
| echo "CLI binary not found at $cli_src" >&2 | |
| exit 1 | |
| fi | |
| rm -rf dist-ui dist-cli | |
| mkdir -p dist-ui dist-cli | |
| cp "$ui_src" "dist-ui/${UI_BIN_NAME}" | |
| chmod +x "dist-ui/${UI_BIN_NAME}" | |
| cp "$cli_src" "dist-cli/${CLI_BIN_NAME}" | |
| chmod +x "dist-cli/${CLI_BIN_NAME}" | |
| # Linux desktop integration helpers | |
| cp "assets/icon.png" "dist-ui/${UI_BIN_NAME}.png" | |
| cp "packaging/linux/${UI_BIN_NAME}.desktop" "dist-ui/${UI_BIN_NAME}.desktop" | |
| cp "packaging/linux/install.sh" "dist-ui/install.sh" | |
| chmod +x "dist-ui/install.sh" | |
| if [[ -f "README.md" ]]; then cp README.md dist-ui/; cp README.md dist-cli/; fi | |
| if [[ -f "README" ]]; then cp README dist-ui/; cp README dist-cli/; fi | |
| if [[ -f "LICENSE" ]]; then cp LICENSE dist-ui/; cp LICENSE dist-cli/; fi | |
| ui_artifact="${UI_BIN_NAME}-${safe_ref}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}" | |
| cli_artifact="${CLI_BIN_NAME}-${safe_ref}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}" | |
| tar -C dist-ui -czf "$ui_artifact" . | |
| tar -C dist-cli -czf "$cli_artifact" . | |
| - name: Package (macOS) | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| safe_ref="$(echo "$GITHUB_REF_NAME" | tr '/\\:*?"<>|' '-')" | |
| ui_src="target/${{ matrix.target }}/release/${UI_BIN_NAME}" | |
| if [[ ! -f "$ui_src" ]]; then | |
| echo "UI binary not found at $ui_src" >&2 | |
| exit 1 | |
| fi | |
| cli_src="target/${{ matrix.target }}/release/${CLI_BIN_NAME}" | |
| if [[ ! -f "$cli_src" ]]; then | |
| echo "CLI binary not found at $cli_src" >&2 | |
| exit 1 | |
| fi | |
| version="${GITHUB_REF_NAME#v}" | |
| rm -rf dist-ui dist-cli | |
| mkdir -p dist-ui dist-cli | |
| app_dir="dist-ui/${MACOS_APP_NAME}.app" | |
| mkdir -p "$app_dir/Contents/MacOS" "$app_dir/Contents/Resources" | |
| cp "$ui_src" "$app_dir/Contents/MacOS/${UI_BIN_NAME}" | |
| chmod +x "$app_dir/Contents/MacOS/${UI_BIN_NAME}" | |
| cp "$cli_src" "dist-cli/${CLI_BIN_NAME}" | |
| chmod +x "dist-cli/${CLI_BIN_NAME}" | |
| # Build icon.icns from assets/icon.png | |
| tmp_icon_dir="$(mktemp -d)" | |
| iconset_dir="$tmp_icon_dir/icon.iconset" | |
| mkdir -p "$iconset_dir" | |
| # Force png output format; avoids occasional sips rename/suffix issues on CI. | |
| sips -s format png -z 16 16 "assets/icon.png" --out "$iconset_dir/icon_16x16.png" >/dev/null | |
| sips -s format png -z 32 32 "assets/icon.png" --out "$iconset_dir/icon_16x16@2x.png" >/dev/null | |
| sips -s format png -z 32 32 "assets/icon.png" --out "$iconset_dir/icon_32x32.png" >/dev/null | |
| sips -s format png -z 64 64 "assets/icon.png" --out "$iconset_dir/icon_32x32@2x.png" >/dev/null | |
| sips -s format png -z 128 128 "assets/icon.png" --out "$iconset_dir/icon_128x128.png" >/dev/null | |
| sips -s format png -z 256 256 "assets/icon.png" --out "$iconset_dir/icon_128x128@2x.png" >/dev/null | |
| sips -s format png -z 256 256 "assets/icon.png" --out "$iconset_dir/icon_256x256.png" >/dev/null | |
| sips -s format png -z 512 512 "assets/icon.png" --out "$iconset_dir/icon_256x256@2x.png" >/dev/null | |
| sips -s format png -z 512 512 "assets/icon.png" --out "$iconset_dir/icon_512x512.png" >/dev/null | |
| sips -s format png -z 1024 1024 "assets/icon.png" --out "$iconset_dir/icon_512x512@2x.png" >/dev/null | |
| iconutil -c icns "$iconset_dir" -o "$app_dir/Contents/Resources/icon.icns" | |
| rm -rf "$tmp_icon_dir" | |
| cat > "$app_dir/Contents/Info.plist" <<EOF | |
| <?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>CFBundleDevelopmentRegion</key> | |
| <string>en</string> | |
| <key>CFBundleExecutable</key> | |
| <string>${UI_BIN_NAME}</string> | |
| <key>CFBundleIdentifier</key> | |
| <string>com.slaveoftime.rustickers</string> | |
| <key>CFBundleInfoDictionaryVersion</key> | |
| <string>6.0</string> | |
| <key>CFBundleName</key> | |
| <string>${MACOS_APP_NAME}</string> | |
| <key>CFBundlePackageType</key> | |
| <string>APPL</string> | |
| <key>CFBundleShortVersionString</key> | |
| <string>${version}</string> | |
| <key>CFBundleVersion</key> | |
| <string>${version}</string> | |
| <key>CFBundleIconFile</key> | |
| <string>icon</string> | |
| <key>LSMinimumSystemVersion</key> | |
| <string>11.0</string> | |
| </dict> | |
| </plist> | |
| EOF | |
| if [[ -f "README.md" ]]; then cp README.md dist-ui/; cp README.md dist-cli/; fi | |
| if [[ -f "README" ]]; then cp README dist-ui/; cp README dist-cli/; fi | |
| if [[ -f "LICENSE" ]]; then cp LICENSE dist-ui/; cp LICENSE dist-cli/; fi | |
| ui_artifact="${UI_BIN_NAME}-${safe_ref}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}" | |
| cli_artifact="${CLI_BIN_NAME}-${safe_ref}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}" | |
| if [[ -f "$ui_artifact" ]]; then rm -f "$ui_artifact"; fi | |
| if [[ -f "$cli_artifact" ]]; then rm -f "$cli_artifact"; fi | |
| ditto -c -k --sequesterRsrc --keepParent "$app_dir" "$ui_artifact" | |
| ditto -c -k --sequesterRsrc --keepParent "dist-cli" "$cli_artifact" | |
| # - name: Upload to GitHub Release | |
| # uses: softprops/action-gh-release@v2 | |
| # with: | |
| # files: | | |
| # ${{ env.UI_BIN_NAME }}-${{ github.ref_name }}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }} | |
| # ${{ env.CLI_BIN_NAME }}-${{ github.ref_name }}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }} | |
| # fail_on_unmatched_files: true |