Skip to content

Commit

Permalink
create action yaml and test
Browse files Browse the repository at this point in the history
  • Loading branch information
andy5995 committed Feb 2, 2024
1 parent 36370bc commit 7caaa12
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Test Action

on:
push:
branches: trunk
pull_request:
branches: trunk

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
platform: ['linux/amd64']
env:
APPDIR: $GITHUB_WORKSPACE/AppDir
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use action from self
id: linuxdeploy
uses: ./
with:
platform: ${{ matrix.platform }}
install_commands: |
sudo apt install -y libncursesw5-dev
build_commands: |
export -p
git clone --depth 1 https://github.com/theimpossibleastronaut/rmw
cd rmw
meson setup _build
cd _build
ninja
meson install --destdir=$APPDIR --skip-subprojects
ld_desktop_file: packaging/rmw.desktop
ld_icon_file: packaging/rmw_icon_32x32.png
ld_icon_filename: rmw
ld_executable_dir: ${{ env.APPDIR }}/usr/bin/rmw

- name: Upload AppImage
uses: actions/upload-artifact@v2
with:
name: appimage
path: ${{ steps.linuxdeploy.outputs.destination_dir }}/out/*.AppImage
19 changes: 19 additions & 0 deletions action-helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

export -p
# Run user-provided build commands
if [ -n '${{ inputs.install_commands }}' ]; then
eval '${{ inputs.install_commands }}'
fi
# Run user-provided build commands
if [ -n '${{ inputs.build_commands }}' ]; then
eval '${{ inputs.build_commands }}'
fi

linuxdeploy \
--appdir $APPDIR \
-d ${{ inputs.ld_desktop_file }} \
--icon-file=${{ inputs.ld_icon_file }} \
--icon-filename=${{ inputs.ld_icon_filename }} \
--executable ${{ inputs.ld_executable }} \
--output appimage
71 changes: 71 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: 'LinuxDeploy Action'
inputs:
platform:
description: 'Target platform for LinuxDeploy'
required: true
default: 'linux/amd64'
install_commands:
description: 'Commands to install dependencies'
required: false
default: ''
build_commands:
description: 'Commands to build the project'
required: false
default: ''
ld_desktop_file:
description: ''
required: true
ld_icon_file:
description: ''
required: true
ld_icon_filename:
description: ''
required: true
ld_executable_dir:
description: 'Executable to deploy'
required: true
ld_appdir:
description: 'Path to target AppDir'
required: true

runs:
using: 'composite'
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Run LinuxDeploy
id: linuxdeploy
shell: bash
run: |
export -p
case ${{ inputs.platform }} in
'linux/amd64')
docker_image='your-docker-image-amd64:latest'
;;
'linux/arm64')
docker_image='your-docker-image-arm64:latest'
;;
*)
echo "Unsupported platform: ${{ inputs.platform }}"
exit 1
;;
esac
export HOSTUID=$(id -u)
docker run \
-e HOSTUID -e APPDIR --rm -v $(pwd):/workspace -w /workspace \
--platform ${{ inputs.platform }} -u root andy5995/linuxdeploy:latest /bin/sh -c \
"usermod -u $HOSTUID builder && su builder -c 'export -p' && \
if [ -n '${{ inputs.install_commands }}' ]; then \
eval '${{ inputs.install_commands }}'; \
fi && \
if [ -n '${{ inputs.build_commands }}' ]; then \
eval '${{ inputs.build_commands }}'; \
fi && \
linuxdeploy \
--appdir $APPDIR \
-d ${{ inputs.ld_desktop_file }} \
--icon-file=${{ inputs.ld_icon_file }} \
--icon-filename=${{ inputs.ld_icon_filename }} \
--executable ${{ inputs.ld_executable }} \
--output appimage"

0 comments on commit 7caaa12

Please sign in to comment.