Skip to content

simplify workflow, split OSes #321

simplify workflow, split OSes

simplify workflow, split OSes #321

name: Build and upload artifacts
on: [push, pull_request]
env:
PD_VERSION: 0.54-1
PDINCLUDEDIR: ./pure-data/src
PDLIBDIR: ./build
LIBNAME: simplex~
jobs:
build_linux:
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux]
arch: [amd64, arm64]
floatsize: [32, 64]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up cross-compilation environment for arm64
if: matrix.arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Clone Pd
run: git clone --branch=${{ env.PD_VERSION }} --depth=1 https://github.com/pure-data/pure-data.git
- name: Compile amd64 external
if: matrix.arch == 'amd64'
run: |
if [ ${{ matrix.floatsize }} -eq 32 ]; then
make install floatsize=${{ matrix.floatsize }} extension=pd_${{ matrix.os }}
else
make install floatsize=${{ matrix.floatsize }} extension=${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.floatsize }}.so
fi
- name: Compile arm64 external
if: matrix.arch == 'arm64'
run: make install floatsize=${{ matrix.floatsize }} extension=${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.floatsize }}.so
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: ${{env.LIBNAME}}-${{ matrix.os }}-${{ matrix.arch }}-pd${{ matrix.floatsize }}
path: build/${{env.LIBNAME}}
build_macos:
runs-on: macos-latest
strategy:
matrix:
os: [darwin]
arch: [amd64, arm64]
floatsize: [32, 64]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Clone Pd
run: git clone --branch=${{ env.PD_VERSION }} --depth=1 https://github.com/pure-data/pure-data.git
- name: Set up environment
run: brew install make
- name: Compile external
run: |
ARCH=${{ matrix.arch == 'amd64' && 'x86_64' || matrix.arch }}
if [ ${{ matrix.floatsize }} -eq 32 ]; then
make install floatsize=${{ matrix.floatsize }} extension=d_${{ matrix.arch }} arch=${ARCH}
elif [ ${{ matrix.floatsize }} -eq 64 ]; then
make install floatsize=${{ matrix.floatsize }} extension=${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.floatsize }}.so arch=${ARCH}
fi
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: ${{env.LIBNAME}}-${{ matrix.os }}-${{ matrix.arch }}-pd${{ matrix.floatsize }}
path: build/${{env.LIBNAME}}
build_windows:
runs-on: windows-latest
strategy:
matrix:
os: [windows]
arch: [amd64]
floatsize: [32, 64]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Download Pure-Data Binaries
run: |
if (${{ matrix.floatsize }} -eq 32) {
Invoke-WebRequest -Uri "http://msp.ucsd.edu/Software/pd-${{env.PD_VERSION}}.msw.zip" -OutFile "pd${{ matrix.floatsize }}-${{env.PD_VERSION}}.msw.zip"
} else {
Invoke-WebRequest -Uri "https://puredata.info/downloads/pure-data/releases/${{env.PD_VERSION}}-pd64/Pd64-${{env.PD_VERSION}}.msw.zip" -OutFile "pd${{ matrix.floatsize }}-${{env.PD_VERSION}}.msw.zip"
}
Expand-Archive -Path "pd${{ matrix.floatsize }}-${{env.PD_VERSION}}.msw.zip" -DestinationPath .
- name: Set up compiler environment
run: |
echo "C:\\msys64\\usr\\bin" >> $GITHUB_PATH # Ensure make and GCC are in PATH
- name: Compile external
shell: bash
run: |
export PATH="/c/msys64/mingw64/bin:$PATH" # Ensure MinGW GCC is preferred if needed
if [ ${{ matrix.floatsize }} -eq 32 ]; then
make install CC=gcc PDINCLUDEDIR="pd-${{env.PD_VERSION}}/src" PDDIR="pd-${{env.PD_VERSION}}" PDBINDIR="pd-${{env.PD_VERSION}}/bin" floatsize=${{ matrix.floatsize }} extension=m_${{ matrix.arch }}
else
make install CC=gcc PDINCLUDEDIR="Pd-0.54.1/src" PDDIR="Pd-0.54.1" PDBINDIR="Pd-0.54.1/bin" floatsize=${{ matrix.floatsize }} extension=${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.floatsize }}.dll
fi
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: ${{env.LIBNAME}}-${{ matrix.os }}-${{ matrix.arch }}-pd${{ matrix.floatsize }}
path: build/${{env.LIBNAME}}
package_release:
runs-on: ubuntu-latest
needs: [build_linux, build_macos, build_windows]
permissions:
contents: write
actions: read
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Rezip Artifacts
run: |
SHORT=${GITHUB_REF:11} # Removes 'refs/tags/' prefix
SLUG=${SHORT//\//_} # Replaces '/' with '_'
for os in linux darwin windows; do
mkdir -p artifacts/$os
mv artifacts/${{env.LIBNAME}}-$os-* artifacts/$os/
zip -r ${{env.LIBNAME}}-${SLUG}-${os}.zip artifacts/$os
done
- name: Upload release content as Artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.LIBNAME}}-release
path: .
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{env.LIBNAME}}*.zip
upload_to_deken:
runs-on: ubuntu-latest
needs: [package_release]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
with:
path: ${{env.LIBNAME}}-src
- uses: actions/download-artifact@v4
with:
name: ${{env.LIBNAME}}
path: ${{env.LIBNAME}}
- name: Create Deken Package and upload
shell: bash
env:
DEKEN_USERNAME: ${{ secrets.DEKEN_USERNAME }}
DEKEN_PASSWORD: ${{ secrets.DEKEN_PASSWORD }}
run: |
SHORT=${GITHUB_REF:11} # remove the 'refs/tags/' prefix
SLUG=${SHORT//\//_} # replace '/' with '_'
if [[ "${GITHUB_REF}" == *"test"* ]]; then
echo "Dry-run: Preparing to package for test tag ${GITHUB_REF}"
mkdir -p ${PWD}/package
docker run --rm --user $(id -u) --volume ${PWD}/${{env.LIBNAME}}:/${{env.LIBNAME}} --volume ${PWD}/package:/package registry.git.iem.at/pd/deken \
deken package --output-dir /package -v "${SLUG}" /${{env.LIBNAME}}
echo "Listing generated Deken files for potential release:"
ls -l ${PWD}/package
echo "Listing contents of the .dek file:"
dek_files=$(ls ${PWD}/package/*.dek)
for dek_file in $dek_files; do
unzip -l "$dek_file"
done
else
docker run --rm -e DEKEN_USERNAME -e DEKEN_PASSWORD --volume ${PWD}/${{env.LIBNAME}}-src:/${{env.LIBNAME}} registry.git.iem.at/pd/deken \
deken upload --name ${{env.LIBNAME}} /${{env.LIBNAME}}
docker run --rm -e DEKEN_USERNAME -e DEKEN_PASSWORD --volume ${PWD}/${{env.LIBNAME}}:/${{env.LIBNAME}} registry.git.iem.at/pd/deken \
deken upload --name ${{env.LIBNAME}} --no-source-error /${{env.LIBNAME}}
fi