Skip to content

Commit

Permalink
Merge pull request #25 from MadBomber/gh_actions
Browse files Browse the repository at this point in the history
Gh actions
  • Loading branch information
MadBomber committed Aug 1, 2022
2 parents 5e6df75 + 3b2404e commit 8d3ccc4
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 26 deletions.
94 changes: 68 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ defaults:
shell: bash

jobs:
build:
all:
name:
Build
All

strategy:
fail-fast: false
matrix:
target:
- aarch64-unknown-linux-gnu
Expand All @@ -38,42 +37,85 @@ jobs:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
native: true

- target: x86_64-apple-darwin
os: macos-latest
native: true

- target: arm64-apple-darwin
os: macos-latest
native: true

- target: x86_64-pc-windows-msvc
os: windows-latest
native: true

- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
native: true

runs-on: ${{ matrix.os }}

steps:
- name: Download source
uses: actions/checkout@v2
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
- name: Install Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Justprep
run: just static=true crystal/build
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: crystal/bin/justprep
asset_name: ${{ matrix.asset-name }}
tag: ${{ github.ref }}
printInputs:
runs-on: ubuntu-latest
steps:
- run: |
echo "Log level: ${{ github.event.inputs.logLevel }}"
echo "Tags: ${{ github.event.inputs.tags }}"
# An issue with BSD Tar causes sporadic failures on macOS.
# c.f https://github.com/actions/cache/issues/403
- name: Install GNU Tar
if: matrix.os == 'macos-latest'
run: |
brew install gnu-tar
echo /usr/local/opt/gnu-tar/libexec/gnubin > $GITHUB_PATH
- name: Update Ubuntu Packages
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
- name: Download source
uses: actions/checkout@v2

- name: Install Crystal
uses: crystal-lang/install-crystal@v1

- name: Install Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Toolchain Versions Used
run: |
just --version
crystal --version
- name: Build Justprep
run: just static=true crystal/build

- name: Package
id: package
if: startsWith(github.ref, 'refs/tags/')
run: ./bin/package ${{github.ref}} ${{matrix.os}} ${{ matrix.target }}
shell: bash

- name: Publish
uses: softprops/action-gh-release@v0.1.5
if: startsWith(github.ref, 'refs/tags/')
with:
draft: false
files: ${{ steps.package.outputs.archive }}
prerelease: ${{ steps.is_prerelease.outputs.value }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Upload binaries to release
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file: crystal/bin/justprep
# asset_name: ${{ matrix.asset-name }}
# tag: ${{ github.ref }}

# printInputs:
# runs-on: ubuntu-latest
# steps:
# - run: |
# echo "Log level: ${{ github.event.inputs.logLevel }}"
# echo "Tags: ${{ github.event.inputs.tags }}"
51 changes: 51 additions & 0 deletions bin/package
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
#
# Adapted from https://github.com/casey/just/blob/master/bin/package
# Intended for use in github actions
#

set -euxo pipefail

REF=$1
OS=$2
TARGET=$3
VERSION=${REF#"refs/tags/"}
DIST=`pwd`/dist
EXECUTABLE=crystal/bin/justprep


echo "Packaging justprep $VERSION for $TARGET..."

echo "Building justprep ..."

just crystal/build


if [[ $OS == windows-latest ]]; then
EXECUTABLE=$EXECUTABLE.exe
fi

echo "Copying release files..."
mkdir dist
cp \
$EXECUTABLE \
LICENSE \
CHANGELOG.md \
README.md \
$DIST

cd $DIST
echo "Creating release archive..."

case "$OS" in
"windows-latest")
ARCHIVE=$DIST/justprep-$VERSION-$TARGET.zip
7z a $ARCHIVE *
echo "::set-output name=archive::`pwd -W`/just-$VERSION-$TARGET.zip"
;;
*)
ARCHIVE=$DIST/justprep-$VERSION-$TARGET.tar.gz
tar czf $ARCHIVE *
echo "::set-output name=archive::$ARCHIVE"
;;
esac

0 comments on commit 8d3ccc4

Please sign in to comment.