Skip to content

Commit

Permalink
build releases automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed May 10, 2023
1 parent 2274ebd commit d3d73ac
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Upload prebuild binaries
on:
release:
types: [published]

jobs:
nightly:
name: Deploy releases
strategy:
fail-fast: false
matrix:
# ubuntu / linux must run on kinda old linux for glibc compatibility!
os: [ubuntu-20.04, windows-latest, macos-latest]
arch: [x86_64]
include:
- os: macos-latest
arch: arm64-apple-macos
arch_short: arm64
cross: "1"
# ARM linux needs to download runtime from ldc, which isn't yet supported with setup-dlang
# - os: ubuntu-20.04
# arch: aarch64-linux-gnu
# arch_short: aarch64
# cross: "1"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- id: vars
shell: bash
run: |
if [ -z "${{matrix.arch_short}}" ]; then
echo "arch_short=${{matrix.arch}}" >> $GITHUB_OUTPUT
else
echo "arch_short=${{matrix.arch_short}}" >> $GITHUB_OUTPUT
fi
- name: Install D compiler
uses: dlang-community/setup-dlang@v1
with:
compiler: ldc-latest

- name: Run tests
run: dub test

# Linux release
- name: Build Linux release
run: ./ci/build.sh
if: matrix.os == 'ubuntu-20.04'
env:
ARCH: ${{ matrix.arch }}
BUILD: release
CROSS: ${{ matrix.cross }}

- name: Deploy Linux release
if: matrix.os == 'ubuntu-20.04'
uses: WebFreak001/upload-asset@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS: linux-${{ steps.vars.outputs.arch_short }}
with:
file: ./sdlfmt.tar.xz
mime: application/x-gtar
name: sdlfmt_${TAG}-${OS}.tar.xz

# OSX release
- name: Build OSX release
run: ./ci/build.sh
if: matrix.os == 'macos-latest'
env:
MACOSX_DEPLOYMENT_TARGET: '10.12'
ARCH: ${{ matrix.arch }}
BUILD: release
CROSS: ${{ matrix.cross }}

- name: Deploy OSX release
if: matrix.os == 'macos-latest'
uses: WebFreak001/upload-asset@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS: osx-${{ steps.vars.outputs.arch_short }}
with:
file: ./sdlfmt.tar.xz
mime: application/x-gtar
name: sdlfmt_${TAG}-${OS}.tar.xz

# Windows release
- name: Build Windows release
run: .\ci\build.bat
if: matrix.os == 'windows-latest'
env:
BUILD: release
ARCH: ${{ matrix.arch }}
CROSS: ${{ matrix.cross }}

- name: Deploy Windows release
if: matrix.os == 'windows-latest'
uses: WebFreak001/upload-asset@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS: windows-${{ steps.vars.outputs.arch_short }}
with:
file: ./sdlfmt.zip
mime: application/zip
name: sdlfmt_${TAG}-${OS}.zip

- name: cache dependency binaries
uses: WebFreak001/[email protected]
with:
store: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sdlfmt.dll
libsdlfmt.a
sdlfmt.lib
sdlfmt-test-*
sdlfmt.tar.xz
sdlfmt.zip
*.exe
*.pdb
*.o
Expand Down
7 changes: 7 additions & 0 deletions ci/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo on

dub build --compiler=ldc2 --build=%BUILD% --arch=%ARCH%

sdlfmt.exe --help

7z a sdlfmt.zip sdlfmt.exe
12 changes: 12 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set -e
set -x

dub build --compiler=ldc2 --build=$BUILD --arch=$ARCH
strip sdlfmt
if [ "$CROSS" = 1 ]; then
ls sdlfmt
else
./sdlfmt --help
fi

tar cfJ sdlfmt.tar.xz sdlfmt

0 comments on commit d3d73ac

Please sign in to comment.