Skip to content

Commit

Permalink
Move build from workflow job to container action
Browse files Browse the repository at this point in the history
- Used apt-get instead of apt because using apt in a script gives the warning message "apt does not have a stable interface".
- Removed usages of sudo just to be consistent (I can't always use sudo because initially sudo isn't installed)
- Added --no-daemon to gradle command because only one gradle command is being run so the daemon isn't necessary.
- Added --quiet to apt-get usages to cut down unuseful lines in logs

Having the action be in a separate actions folder may not be desirable, in which case I can probably move the action into the workflow folder somewhere but I'm not sure where.

Copy my docker action from my similar PR in Jamepad

Copied from libgdx/Jamepad#34 Similar structure should work, but will of course need to adjust to suit the libgdx action
  • Loading branch information
SonicGDX committed Dec 14, 2024
1 parent 980fa73 commit d444612
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 54 deletions.
8 changes: 8 additions & 0 deletions .github/actions/build-linux-natives/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Container image that runs your code
FROM ubuntu:18.04

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
6 changes: 6 additions & 0 deletions .github/actions/build-linux-natives/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# action.yml
name: 'Build Linux Natives in Docker Container'
description: 'Build Linux Natives in Ubuntu 18.04 docker container'
runs:
using: 'docker'
image: 'Dockerfile'
43 changes: 43 additions & 0 deletions .github/actions/build-linux-natives/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh -l

# ubuntu dockerfile is very minimal (only 122 packages are installed)
# need to install updated git (from official git ppa)
apt-get update
apt-get -yq install software-properties-common
add-apt-repository ppa:git-core/ppa -y
# install dependencies expected by other steps
apt-get -q update
apt-get install -yq git \
curl \
ca-certificates \
wget \
bzip2 \
zip \
unzip \
xz-utils \
sudo locales

# set Locale to en_US.UTF-8 (avoids hang during compilation)
locale-gen en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

# add zulu apt repository - https://docs.azul.com/core/install/debian
curl -s https://repos.azul.com/azul-repo.key | gpg --dearmor -o /usr/share/keyrings/azul.gpg
echo "deb [signed-by=/usr/share/keyrings/azul.gpg] https://repos.azul.com/zulu/deb stable main" | tee /etc/apt/sources.list.d/zulu.list
apt-get -q update
# install zulu JDK and Java build tools
apt-get -yq install zulu17-jdk-headless maven ant

# Install cross-compilation toolchains
apt-get install -yq --force-yes gcc g++
apt-get install -yq --force-yes gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
apt-get install -yq --force-yes gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross

# Build Linux natives
./gradlew jniGen jnigenBuildLinux64 jnigenBuildLinuxARM jnigenBuildLinuxARM64 --no-daemon

# Pack artifacts
find . -name "*.a" -o -name "*.dll" -o -name "*.dylib" -o -name "*.so" | grep "libs" > native-files-list
zip natives-linux -@ < native-files-list
59 changes: 5 additions & 54 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,67 +89,18 @@ jobs:

natives-linux:
runs-on: ubuntu-20.04
container:
image: ubuntu:18.04
steps:
- name: Install dependencies into minimal dockerfile
run: |
# ubuntu dockerfile is very minimal (only 122 packages are installed)
# need to install updated git (from official git ppa)
apt update
apt install -y software-properties-common
add-apt-repository ppa:git-core/ppa -y
# install dependencies expected by other steps
apt update
apt install -y git \
curl \
ca-certificates \
wget \
bzip2 \
zip \
unzip \
xz-utils \
maven \
ant sudo locales
# set Locale to en_US.UTF-8 (avoids hang during compilation)
locale-gen en_US.UTF-8
echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
echo "LANGUAGE=en_US.UTF-8" >> $GITHUB_ENV
echo "LC_ALL=en_US.UTF-8" >> $GITHUB_ENV
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Install cross-compilation toolchains
run: |
sudo apt update
sudo apt install -y --force-yes gcc g++
sudo apt install -y --force-yes gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
sudo apt install -y --force-yes gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross
- name: Build Linux natives
run: |
./gradlew jniGen jnigenBuildLinux64 jnigenBuildLinuxARM jnigenBuildLinuxARM64
- name: Pack artifacts
run: |
find . -name "*.a" -o -name "*.dll" -o -name "*.dylib" -o -name "*.so" | grep "libs" > native-files-list
zip natives-linux -@ < native-files-list
- name: Build Linux Natives in Docker Container
uses: ./.github/actions/build-linux-natives
id: docker

- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: natives-linux.zip
path: natives-linux.zip
Expand Down

0 comments on commit d444612

Please sign in to comment.