Skip to content

Commit

Permalink
GitHub workfows and MacOS installer
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorc committed Jul 10, 2024
1 parent 8c3baef commit e0fe474
Show file tree
Hide file tree
Showing 23 changed files with 778 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: BuildLinux

on:
workflow_call:
inputs:
name:
required: true
type: string

jobs:
papercraft:
name: ${{ inputs.name }}
# Oldest LTS ubuntu still with support
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Bin dir
run: |
mkdir bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: LinuxDeploy
run: |
( cd bin ; wget -nv https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage )
chmod a+x bin/linuxdeploy-x86_64.AppImage
- name: Hack g++
run: |
# Old G++ doesn't support -std=c++20, but it does support -std=c++2a
# This script hacks that
cp distro/docker/g++ bin/g++
cp distro/docker/g++ bin/c++
- name: Build
run: |
cargo build --release
- name: Pack AppImage
run: |
export LINUXDEPLOY_OUTPUT_VERSION="${{ inputs.name }}"
export ARCH=x86_64
# Create the directory tree
linuxdeploy-x86_64.AppImage --appdir=AppDir
mkdir -p AppDir/usr/share/metainfo/
cp distro/papercraft.desktop AppDir/usr/share/applications/
cp distro/com.rodrigorc.papercraft.appdata.xml AppDir/usr/share/metainfo/
cp target/release/papercraft AppDir/usr/bin/
cp src/papercraft.png AppDir/usr/share/icons/hicolor/128x128/apps/
linuxdeploy-x86_64.AppImage \
--appdir=AppDir \
--desktop-file=AppDir/usr/share/applications/papercraft.desktop \
--output appimage \
--exclude-library="libglib-2.0.*" \
--custom-apprun=distro/docker/apprun
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Papercraft-${{ inputs.name }}-x86_64.AppImage
path: Papercraft-${{ inputs.name }}-x86_64.AppImage
if-no-files-found: error
67 changes: 67 additions & 0 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: BuildMacOS

on:
workflow_call:
inputs:
name:
type: string
required: true
workflow_dispatch:
inputs:
name:
type: string
required: true

jobs:
papercraft:
name: ${{ inputs.name }}
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Rustup
run: |
rustup target add x86_64-apple-darwin
- name: Create DMG
run: |
brew install create-dmg
- name: Build x86
run: |
cargo build --release --target=x86_64-apple-darwin
- name: Build Arm86
run: |
cargo build --release --target=aarch64-apple-darwin
- name: Build DMG
run: |
mkdir -p app_folder/Papercraft.app/Contents/MacOS
mkdir -p app_folder/Papercraft.app/Contents/Resources
cd distro/macos
iconutil -c icns papercraft.iconset
cd ../..
cp distro/macos/papercraft.icns app_folder/Papercraft.app/Contents/Resources/Papercraft.icns
cp distro/macos/PkgInfo app_folder/Papercraft.app/Contents/
cp distro/macos/Info.plist app_folder/Papercraft.app/Contents/
lipo -create target/aarch64-apple-darwin/release/papercraft target/x86_64-apple-darwin/release/papercraft -output \
app_folder/Papercraft.app/Contents/MacOS/Papercraft
create-dmg \
--volname "Papercraft" \
--volicon "distro/macos/papercraft.icns" \
--background "distro/macos/installer_background.png" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "Papercraft.app" 200 200 \
--app-drop-link 600 200 \
--hide-extension "Papercraft.app" \
"Papercraft-${{ inputs.name }}-MacOS.dmg" \
"app_folder/"
- name: Upload artifact MacOS
uses: actions/upload-artifact@v4
with:
name: Papercraft-${{ inputs.name }}-MacOS.dmg
path: Papercraft-${{ inputs.name }}-MacOS.dmg
if-no-files-found: error

59 changes: 59 additions & 0 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: BuildRelease

on:
workflow_call:
inputs:
tag_name:
type: string
required: true

jobs:
build_linux:
name: BuildLinux
uses: ./.github/workflows/build_linux.yml
with:
name: ${{ inputs.tag_name }}
build_win32:
name: BuildWin32
uses: ./.github/workflows/build_win32.yml
with:
name: ${{ inputs.tag_name }}
build_win64:
name: BuildWin64
uses: ./.github/workflows/build_win64.yml
with:
name: ${{ inputs.tag_name }}
build_macos:
name: BuildMacOS
uses: ./.github/workflows/build_macos.yml
with:
name: ${{ inputs.tag_name }}
release:
name: Release
needs: [build_linux, build_win32, build_win64, build_macos]
runs-on: ubuntu-latest
steps:
- name: Download Linux
uses: actions/download-artifact@v4
with:
name: Papercraft-${{ inputs.tag_name }}-x86_64.AppImage
- name: Download Win32
uses: actions/download-artifact@v4
with:
name: Papercraft-${{ inputs.tag_name }}-win32.zip
- name: Download Win64
uses: actions/download-artifact@v4
with:
name: Papercraft-${{ inputs.tag_name }}-win64.zip
- name: Download MacOS
uses: actions/download-artifact@v4
with:
name: Papercraft-${{ inputs.tag_name }}-MacOS.dmg
- name: Upload all to release
uses: svenstaro/upload-release-action@2.9.0
with:
tag: ${{ inputs.tag_name }}
prerelease: true
file_glob: true
file: Papercraft-${{ inputs.tag_name }}-*

49 changes: 49 additions & 0 deletions .github/workflows/build_win32.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: BuildWin32

on:
workflow_call:
inputs:
name:
required: true
type: string

jobs:
papercraft:
name: ${{ inputs.name }}
runs-on: ubuntu-latest
steps:
- name: Install pre-requisites
run: |
rustup target add i686-pc-windows-gnu
sudo apt-get install -y gcc-mingw-w64 g++-mingw-w64 libz-mingw-w64-dev
sudo ln -s /usr/lib/gcc/i686-w64-mingw32/10-win32/include/c++ /usr/i686-w64-mingw32/include/c++
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Build Win32
run: |
env PKG_CONFIG_ALLOW_CROSS="1" \
PKG_CONFIG_LIBDIR="/usr/i686-w64-mingw32/lib/pkgconfig/" \
WINDRES=i686-w64-mingw32-windres \
RUSTFLAGS="-Clink-arg=-mwindows" \
CARGO_TARGET_DIR=win32target \
cargo build --release --target i686-pc-windows-gnu
- name: Pkg win32
run: |
mkdir -p pkg32/papercraft
cd pkg32/papercraft
ln -s ../../win32target/i686-pc-windows-gnu/release/papercraft.exe .
ln -s /usr/lib/gcc/i686-w64-mingw32/10-win32/libstdc++-6.dll .
ln -s /usr/lib/gcc/i686-w64-mingw32/10-win32/libgcc_s_dw2-1.dll .
mkdir examples
cd examples
ln -s ../../../examples/*.craft .
cd ../..
zip -r "../Papercraft-${{ inputs.name }}-win32.zip" papercraft
- name: Upload artifact win32
uses: actions/upload-artifact@v4
with:
name: Papercraft-${{ inputs.name }}-win32.zip
path: Papercraft-${{ inputs.name }}-win32.zip
if-no-files-found: error
40 changes: 40 additions & 0 deletions .github/workflows/build_win32native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: BuildWin32Native

on:
workflow_dispatch:
inputs:
name:
required: true
type: string

jobs:
papercraft:
name: ${{ inputs.name }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: VS
uses: ilammy/msvc-dev-cmd@v1
- name: Build Win32
run: |
$env:RC="rc.exe"
cargo build --release --target=i686-pc-windows-msvc
- name: Pkg win32
run: |
mkdir pkg32/papercraft
cd pkg32/papercraft
copy ../../target/i686-pc-windows-msvc/release/papercraft.exe .
mkdir examples
cd examples
copy ../../../examples/*.craft .
cd ../..
7z a "../Papercraft-${{ inputs.name }}-win32.zip" papercraft
- name: Upload artifact win32
uses: actions/upload-artifact@v4
with:
name: Papercraft-${{ inputs.name }}-win32.zip
path: Papercraft-${{ inputs.name }}-win32.zip
if-no-files-found: error
49 changes: 49 additions & 0 deletions .github/workflows/build_win64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: BuildWin64

on:
workflow_call:
inputs:
name:
required: true
type: string

jobs:
papercraft:
name: ${{ inputs.name }}
runs-on: ubuntu-latest
steps:
- name: Install pre-requisites
run: |
rustup target add x86_64-pc-windows-gnu
sudo apt-get install -y gcc-mingw-w64 g++-mingw-w64 libz-mingw-w64-dev
sudo ln -s /usr/lib/gcc/x86_64-w64-mingw32/10-win32/include/c++ /usr/x86_64-w64-mingw32/include/c++
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Build Win64
run: |
env PKG_CONFIG_ALLOW_CROSS="1" \
PKG_CONFIG_LIBDIR="/usr/x86_64-w64-mingw32/lib/pkgconfig/" \
WINDRES=x86_64-w64-mingw32-windres \
RUSTFLAGS="-Clink-arg=-mwindows" \
CARGO_TARGET_DIR=win64target \
cargo build --release --target x86_64-pc-windows-gnu
- name: Pkg win64
run: |
mkdir -p pkg64/papercraft
cd pkg64/papercraft
ln -s ../../win64target/x86_64-pc-windows-gnu/release/papercraft.exe .
ln -s /usr/lib/gcc/x86_64-w64-mingw32/10-win32/libstdc++-6.dll .
ln -s /usr/lib/gcc/x86_64-w64-mingw32/10-win32/libgcc_s_seh-1.dll .
mkdir examples
cd examples
ln -s ../../../examples/*.craft .
cd ../..
zip -r "../Papercraft-${{ inputs.name }}-win64.zip" papercraft
- name: Upload artifact win64
uses: actions/upload-artifact@v4
with:
name: Papercraft-${{ inputs.name }}-win64.zip
path: Papercraft-${{ inputs.name }}-win64.zip
if-no-files-found: error
40 changes: 40 additions & 0 deletions .github/workflows/build_win64native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: BuildWin64Native

on:
workflow_dispatch:
inputs:
name:
required: true
type: string

jobs:
papercraft:
name: ${{ inputs.name }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: VS
uses: ilammy/msvc-dev-cmd@v1
- name: Build Win64
run: |
$env:RC="rc.exe"
cargo build --release --target=x86_64-pc-windows-msvc
- name: Pkg win64
run: |
mkdir pkg64/papercraft
cd pkg64/papercraft
copy ../../target/x86_64-pc-windows-msvc/release/papercraft.exe .
mkdir examples
cd examples
copy ../../../examples/*.craft .
cd ../..
7z a "../Papercraft-${{ inputs.name }}-win64.zip" papercraft
- name: Upload artifact win64
uses: actions/upload-artifact@v4
with:
name: Papercraft-${{ inputs.name }}-win64.zip
path: Papercraft-${{ inputs.name }}-win64.zip
if-no-files-found: error
17 changes: 17 additions & 0 deletions .github/workflows/manual_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ManualRelease

on:
workflow_dispatch:
inputs:
tag_name:
type: string
required: true

jobs:
build_release:
permissions:
contents: write
name: BuildRelease
uses: ./.github/workflows/build_release.yml
with:
tag_name: ${{ inputs.tag_name }}
Loading

0 comments on commit e0fe474

Please sign in to comment.