Skip to content

Commit

Permalink
github actions: separate build for each OS
Browse files Browse the repository at this point in the history
It's dumber but also clearer. I'm sick of debugging dumb GH Action
mistakes.
  • Loading branch information
nhanb committed Jul 10, 2022
1 parent ea48589 commit c679694
Showing 1 changed file with 92 additions and 19 deletions.
111 changes: 92 additions & 19 deletions .github/workflows/main.yml
Expand Up @@ -5,13 +5,8 @@ on:

jobs:

build-everything:

strategy:
matrix:
os: [ubuntu-latest, macos-10.15]

runs-on: ${{ matrix.os }}
build-linux:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
Expand All @@ -20,32 +15,63 @@ jobs:
go-version: 1.18

- name: Install ebiten linux deps
if: runner.os == 'Linux'
run: make deps-debian

- name: Build for ${{ runner.os }}
- name: Build for Linux
env:
TAG: ${{ github.ref_name }}
run: make $(echo ${{ runner.os }} | tr '[:upper:]' '[:lower:]')
# The `tr` stuff is to convert the string to lowercase
run: make linux

- name: Zip first to prevent GH Artifacts from removing the executable flag
run: |
cd dist
zip -vr "shark-${{ runner.os }}.zip" .
zip -vr "shark-linux.zip" .
- name: Upload ${{ runner.os }} build
- name: Upload linux build
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }} shark
path: dist/shark-${{ runner.os }}.zip
name: Linux shark
path: dist/shark-linux.zip

- name: Cross-compile Windows build
- name: Upload artifacts to tagged release
if: github.ref_type == 'tag'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
# Because we have multiple OSes in the build matrix, we need to either
# create a new release, or upload to the release if it already exists.
if gh release view "$TAG"; then
gh release upload "$TAG" dist/*.zip
else
# Work around GH being daft:
# https://github.com/actions/checkout/issues/290
git fetch --force --tags
echo '```' > RELEASE_NOTES
git tag -l --format='%(contents)' "$TAG" >> RELEASE_NOTES
echo '```' >> RELEASE_NOTES
cat RELEASE_NOTES
gh release create "$TAG" dist/*.zip -F RELEASE_NOTES
fi
build-windows:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Install ebiten linux deps
if: runner.os == 'Linux'
run: make deps-debian

- name: Cross-compile Windows build
run: make windows

- name: Upload cross-compiled Windows build
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: Windows shark
Expand All @@ -60,7 +86,54 @@ jobs:
# Because we have multiple OSes in the build matrix, we need to either
# create a new release, or upload to the release if it already exists.
if gh release view "$TAG"; then
gh release upload "$TAG" dist/*.zip dist/*.exe
gh release upload "$TAG" dist/*.exe
else
# Work around GH being daft:
# https://github.com/actions/checkout/issues/290
git fetch --force --tags
echo '```' > RELEASE_NOTES
git tag -l --format='%(contents)' "$TAG" >> RELEASE_NOTES
echo '```' >> RELEASE_NOTES
cat RELEASE_NOTES
gh release create "$TAG" dist/*.exe -F RELEASE_NOTES
fi
build-macos:
runs-on: macos-10.15

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Build for macOS
env:
TAG: ${{ github.ref_name }}
run: make macos

- name: Zip first to prevent GH Artifacts from removing the executable flag
run: |
cd dist
zip -vr "shark-macos.zip" .
- name: Upload macOS build
uses: actions/upload-artifact@v3
with:
name: macOS shark
path: dist/shark-macos.zip

- name: Upload artifacts to tagged release
if: github.ref_type == 'tag'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
# Because we have multiple OSes in the build matrix, we need to either
# create a new release, or upload to the release if it already exists.
if gh release view "$TAG"; then
gh release upload "$TAG" dist/*.zip
else
# Work around GH being daft:
# https://github.com/actions/checkout/issues/290
Expand All @@ -70,5 +143,5 @@ jobs:
git tag -l --format='%(contents)' "$TAG" >> RELEASE_NOTES
echo '```' >> RELEASE_NOTES
cat RELEASE_NOTES
gh release create "$TAG" dist/*.zip dist/*.exe -F RELEASE_NOTES
gh release create "$TAG" dist/*.zip -F RELEASE_NOTES
fi

0 comments on commit c679694

Please sign in to comment.