Skip to content

Commit

Permalink
Build: Automatically publish release after tagging (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom authored Oct 9, 2020
1 parent 4fa248a commit d4c6e26
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 14 deletions.
13 changes: 12 additions & 1 deletion .github/bin/build
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/usr/bin/env sh

nimble install -d -Y
nimble build -d:release --passC:'-flto' --passL='-s' --passL='-static' --gcc.exe=musl-gcc --gcc.linkerexe=musl-gcc

case "$OS" in
windows)
nimble build -d:release --passC:'-flto' --passL='-s' --passL='-static'
;;
linux)
nimble build -d:release --passC:'-flto' --passL='-s' --passL='-static'
;;
macosx)
nimble build -d:release
;;
esac
23 changes: 23 additions & 0 deletions .github/bin/create-artifact
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env sh

ARTIFACTS_DIR="artifacts"
mkdir -p $ARTIFACTS_DIR

BINARY_NAME="canonicaldatasyncer"

case "$OS" in
windows)
ARTIFACT_FILE="$ARTIFACTS_DIR/$BINARY_NAME-$OS-$ARCH.zip"
7z a $ARTIFACT_FILE $BINARY_NAME.exe
;;
linux)
ARTIFACT_FILE="$ARTIFACTS_DIR/$BINARY_NAME-$OS-$ARCH.tgz"
tar -cvzf $ARTIFACT_FILE $BINARY_NAME
;;
macosx)
ARTIFACT_FILE="$ARTIFACTS_DIR/$BINARY_NAME-$OS-$ARCH.tgz"
tar -cvzf $ARTIFACT_FILE $BINARY_NAME
;;
esac

echo "ARTIFACT_FILE=${ARTIFACT_FILE}" >> "${GITHUB_ENV}"
3 changes: 0 additions & 3 deletions .github/bin/install-build-tools

This file was deleted.

4 changes: 4 additions & 0 deletions .github/bin/publish-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh

gh release create $TAG
gh release upload $TAG $ARTIFACT_FILE
53 changes: 43 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,34 @@ name: Build

on:
push:
branches: [master]
paths: ["**.nim"]
pull_request:
branches: [master]
paths: ["**.nim"]
tags:
- "*"

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- os: linux
arch: 64-bit
- os: macosx
arch: 64-bit
- os: windows
arch: 64-bit
include:
- target:
os: linux
builder: ubuntu-18.04
- target:
os: macosx
builder: macos-10.15
- target:
os: windows
builder: windows-2019

name: "${{ matrix.target.os }}-${{ matrix.target.arch }}"
runs-on: ${{ matrix.builder }}
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -21,8 +39,23 @@ jobs:
with:
nim-version: "1.2.6"

- name: Install Nim build tools
run: ./.github/bin/install-build-tools

- name: Build binary
shell: bash
run: ./.github/bin/build
env:
OS: ${{ matrix.target.os }}
ARCH: ${{ matrix.target.arch }}

- name: Create artifact
shell: bash
run: ./.github/bin/create-artifact
env:
OS: ${{ matrix.target.os }}
ARCH: ${{ matrix.target.arch }}

- name: Publish release
shell: bash
run: ./.github/bin/publish-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref }}

0 comments on commit d4c6e26

Please sign in to comment.