Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Dockerfile and script for building in container instead of running the entire job in the container #34

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3f4b0e6
Add dockerfile and entrypoint.sh
SonicGDX Nov 25, 2024
9c02c0e
test ls
SonicGDX Nov 27, 2024
3349e52
Fix docker action not being called
SonicGDX Nov 27, 2024
859393e
Fix "Can't find 'action.yml', 'action.yaml' or 'Dockerfile"
SonicGDX Nov 27, 2024
ae551ff
add execute permission for entrypoint.sh
SonicGDX Nov 27, 2024
d19d06b
Add most of the rest of the job to the docker script
SonicGDX Nov 27, 2024
dcc7331
Install Zulu in docker container
SonicGDX Nov 27, 2024
f00b905
Fix script mistakes
SonicGDX Nov 27, 2024
882b29b
Read and re-add gradle build action
SonicGDX Nov 27, 2024
132db5b
Fix gradle permission denied error in setup gradle setup once docker …
SonicGDX Nov 27, 2024
8f7ebcf
Exit if cd fails in docker script
SonicGDX Nov 27, 2024
1447c42
Use apt-get and sudo consistently
SonicGDX Nov 27, 2024
fa7772d
Use headless zulu and remove unnecessary apt install line
SonicGDX Nov 27, 2024
698ce1e
Actually remove .gradle folder
SonicGDX Nov 27, 2024
062ca39
Remove usages of sudo in entrypoint.sh
SonicGDX Nov 27, 2024
9eb4517
Remove openjdk-11-jdk-headless install
SonicGDX Nov 27, 2024
a748272
Move snapshot build inside docker script
SonicGDX Nov 27, 2024
ffe9562
Read setup java action
SonicGDX Nov 27, 2024
d559e8a
Remove template inputs /outputs from action
SonicGDX Nov 27, 2024
65089f7
Export language environment variables properly
SonicGDX Nov 27, 2024
d43b263
Move maven and ant installation until when zulu is installed
SonicGDX Nov 27, 2024
7f31c70
Add --quiet to the other apt-get installs
SonicGDX Nov 27, 2024
629c351
Use latest versions of actions
SonicGDX Nov 27, 2024
e828bb2
Revert update of gradle-build-action
SonicGDX Nov 27, 2024
aaa90ea
Add comments explaining the sources.list edits
SonicGDX Nov 28, 2024
5904816
Use docker script for release action as well
SonicGDX Dec 3, 2024
c553462
Use -quiet for all apt-get update usages and use consistent option or…
SonicGDX Dec 3, 2024
02e82bf
Use if condition for setting up JDK and Gradle in push action
SonicGDX Dec 3, 2024
768cf30
Build snapshot/release in runner instead of in container
SonicGDX Dec 3, 2024
6e9c836
Disable daemon for macos build as well
SonicGDX Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/actions/docker/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/docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# action.yml
name: 'Build Linux Natives in Docker'
description: 'Build Linux Natives in Ubuntu 18.04 docker container'
runs:
using: 'docker'
image: 'Dockerfile'
104 changes: 104 additions & 0 deletions .github/actions/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/sh -l

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


# 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

# default Ubuntu jammy archive doesn't support armhf or arm64
# so remove those architectures in this list to avoid invalid URL errors
sed -i 's/deb http/deb [arch=amd64,i386] http/' /etc/apt/sources.list
# make a copy of sources.list that we'll use for armhf and arm64 ports
grep "ubuntu.com/ubuntu" /etc/apt/sources.list | tee /etc/apt/sources.list.d/ports.list
sed -i 's/amd64,i386/armhf,arm64/' /etc/apt/sources.list.d/ports.list
# change URLs in ports.list to use Ubuntu ports repo
sed -i 's#http://.*/ubuntu#http://ports.ubuntu.com/ubuntu-ports#' /etc/apt/sources.list.d/ports.list
# Add extra platform architectures
dpkg --add-architecture i386; dpkg --add-architecture armhf; dpkg --add-architecture arm64
apt-get -q update

# install zulu and java build tools
apt-get -yq install zulu8-jdk-headless maven ant

# Install Windows compilers
apt-get -yq install g++-mingw-w64-i686 g++-mingw-w64-x86-64
# Install Linux x86 compilers/libraries
apt-get -yq install gcc-multilib g++-multilib linux-libc-dev:i386
# Install Linux arm32 compilers/libraries
apt-get -yq install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
# Install Linux arm64 compilers/libraries
apt-get -yq install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu

find . -type f -path "SDL/*.h" -exec sed -i 's/extern DECLSPEC//' {} \;
sed -i 's/#define SDL_DYNAMIC_API 1/#define SDL_DYNAMIC_API 0/' SDL/src/dynapi/SDL_dynapi.h

mkdir -p SDL/build-linux64
cd SDL/build-linux64 || exit
../configure CFLAGS="-fPIC" CPPFLAGS="-fPIC" --disable-audio --disable-video --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi
make -j
cd - || exit

mkdir -p SDL/build-linux32
cd SDL/build-linux32 || exit
../configure CFLAGS="-fPIC -m32" CPPFLAGS="-fPIC -m32" LDFLAGS="-m32" --disable-audio --disable-video --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi
make -j
cd - || exit

mkdir -p SDL/build-linuxarm32
cd SDL/build-linuxarm32 || exit
../configure --host=arm-linux-gnueabihf CFLAGS="-fPIC" CPPFLAGS="-fPIC" --disable-audio --disable-video --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi
make -j
cd - || exit

mkdir -p SDL/build-linuxarm64
cd SDL/build-linuxarm64 || exit
../configure --host=aarch64-linux-gnu CFLAGS="-fPIC" CPPFLAGS="-fPIC" --disable-audio --disable-video --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi
make -j
cd - || exit

mkdir -p SDL/build-windows32
cd SDL/build-windows32 || exit
../configure --host=i686-w64-mingw32 --disable-audio --disable-render --disable-power --disable-filesystem --disable-hidapi
make -j
cd - || exit

mkdir -p SDL/build-windows64
cd SDL/build-windows64 || exit
../configure --host=x86_64-w64-mingw32 --disable-audio --disable-render --disable-power --disable-filesystem --disable-hidapi
make -j
cd - || exit

# Grant execute permission for gradlew
chmod +x gradlew
# Build with Gradle
./gradlew jnigen jnigenBuild jnigenJarNativesDesktop --no-daemon

# clean up gradle files before handing back to runner
rm -rf .gradle
132 changes: 27 additions & 105 deletions .github/workflows/pushaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
submodules: 'recursive'

- name: Set up JDK 8
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 8
Expand All @@ -43,137 +43,59 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew jnigen jnigenBuild
run: ./gradlew jnigen jnigenBuild --no-daemon
- name: Upload macOS natives
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: macos-natives
path: libs

linux:
needs: macos
runs-on: ubuntu-20.04
container: ubuntu:18.04
env:
ORG_GRADLE_PROJECT_GITHUB_USERNAME: ""
ORG_GRADLE_PROJECT_GITHUB_API_TOKEN: ""
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 \
openjdk-11-jdk-headless \
maven \
build-essential \
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@v3
- uses: actions/checkout@v4
with:
submodules: 'recursive'

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

- name: Setup Gradle
uses: gradle/[email protected]

- run: sudo sed -i 's/deb http/deb [arch=amd64,i386] http/' /etc/apt/sources.list
- run: grep "ubuntu.com/ubuntu" /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/ports.list
- run: sudo sed -i 's/amd64,i386/armhf,arm64/' /etc/apt/sources.list.d/ports.list
- run: sudo sed -i 's#http://.*/ubuntu#http://ports.ubuntu.com/ubuntu-ports#' /etc/apt/sources.list.d/ports.list
- name: Add extra platform architectures
run: sudo dpkg --add-architecture i386; sudo dpkg --add-architecture armhf; sudo dpkg --add-architecture arm64
- run: sudo apt-get update
- name: Install Windows compilers
run: sudo apt-get -yq install g++-mingw-w64-i686 g++-mingw-w64-x86-64
- name: Install Linux x86 compilers/libraries
run: sudo apt-get -yq install gcc-multilib g++-multilib linux-libc-dev:i386
- name: Install Linux arm32 compilers/libraries
run: sudo apt-get -yq install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
- name: Install Linux arm64 compilers/libraries
run: sudo apt-get -yq install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
- name: Download macOS natives
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: macos-natives
path: libs

- run: find -type f -name "*.h" -exec sed -i 's/extern DECLSPEC//' {} \;
working-directory: SDL
- run: sed -i 's/#define SDL_DYNAMIC_API 1/#define SDL_DYNAMIC_API 0/' SDL/src/dynapi/SDL_dynapi.h

- run: mkdir -p SDL/build-linux64
- run: ../configure CFLAGS="-fPIC" CPPFLAGS="-fPIC" --disable-audio --disable-video --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi
working-directory: SDL/build-linux64
- run: make -j
working-directory: SDL/build-linux64

- run: mkdir -p SDL/build-linux32
- run: ../configure CFLAGS="-fPIC -m32" CPPFLAGS="-fPIC -m32" LDFLAGS="-m32" --disable-audio --disable-video --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi
working-directory: SDL/build-linux32
- run: make -j
working-directory: SDL/build-linux32

- run: mkdir -p SDL/build-linuxarm32
- run: ../configure --host=arm-linux-gnueabihf CFLAGS="-fPIC" CPPFLAGS="-fPIC" --disable-audio --disable-video --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi
working-directory: SDL/build-linuxarm32
- run: make -j
working-directory: SDL/build-linuxarm32

- run: mkdir -p SDL/build-linuxarm64
- run: ../configure --host=aarch64-linux-gnu CFLAGS="-fPIC" CPPFLAGS="-fPIC" --disable-audio --disable-video --disable-video-vulkan --disable-render --disable-filesystem --disable-threads --disable-directx --disable-mmx --disable-3dnow --disable-sse --disable-sse2 --disable-sse3 --disable-cpuinfo --disable-sensor --enable-hidapi
working-directory: SDL/build-linuxarm64
- run: make -j
working-directory: SDL/build-linuxarm64

- run: mkdir -p SDL/build-windows32
- run: ../configure --host=i686-w64-mingw32 --disable-audio --disable-render --disable-power --disable-filesystem --disable-hidapi
working-directory: SDL/build-windows32
- run: make -j
working-directory: SDL/build-windows32
# Build natives in docker container
- name: Build in Docker Container
uses: ./.github/actions/docker
id: docker

- run: mkdir -p SDL/build-windows64
- run: ../configure --host=x86_64-w64-mingw32 --disable-audio --disable-render --disable-power --disable-filesystem --disable-hidapi
working-directory: SDL/build-windows64
- run: make -j
working-directory: SDL/build-windows64

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew jnigen jnigenBuild jnigenJarNativesDesktop
- name: Upload all output libs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: output-libs
path: build/libs/
- name: Snapshot build
run:
./gradlew build
- name: Snapshot deploy


- name: Set up JDK 8
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository_owner == 'libgdx'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 8

- name: Setup Gradle
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository_owner == 'libgdx'
uses: gradle/[email protected]

# Snapshot was built inside docker container
- name: Snapshot build deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository_owner == 'libgdx'
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
run:
./gradlew publish
# Execute permission was granted in the docker script
./gradlew build publish --no-daemon
Loading