Releases #920
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Releases | |
on: | |
schedule: | |
- cron: '0 0 * * *' # midnight UTC | |
push: | |
tags: | |
- v* | |
workflow_dispatch: | |
jobs: | |
# Check to see whether there have been any commits since the last run, | |
# letting us skip subsequent steps if there haven't. | |
# https://github.community/t/trigger-action-on-schedule-only-if-there-are-changes-to-the-branch/17887 | |
check_date: | |
runs-on: ubuntu-18.04 | |
name: Check latest commit | |
outputs: | |
should_run: ${{ steps.should_run.outputs.should_run }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: print latest_commit | |
run: echo ${{ github.sha }} | |
- id: should_run | |
continue-on-error: true | |
name: Check for recent changes | |
if: ${{ github.event_name == 'schedule' }} | |
run: | | |
# We want to re-run if the nightly tag doesn't already exist (which | |
# causes git rev-list to fail) or when there are commits which are | |
# accessible from this commit but not already under the nightly tag | |
commits_since_last_nightly=$(git rev-list ${{ github.sha }} '^nightly') | |
if [ $? -eq 0 -a -z "$commits_since_last_nightly" ]; then | |
echo "::set-output name=should_run::false" | |
fi | |
build: | |
name: Build release artifacts for ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
needs: check_date | |
if: ${{ needs.check_date.outputs.should_run != 'false' }} | |
strategy: | |
matrix: | |
include: | |
- name: linux | |
os: ubuntu-18.04 | |
artifact_name: "target/rune.*.zip" | |
asset_name: rune-linux | |
# - name: windows | |
# os: windows-latest | |
# artifact_name: "target/rune.*.zip" | |
# asset_name: rune-windows | |
# HACK: Disabling macos builds due to https://github.com/hotg-ai/librunecoral/issues/43 | |
- name: macos | |
os: macos-latest | |
artifact_name: "target/rune.*.zip" | |
asset_name: rune-macos | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-${{ github.workflow }}-${{ github.job }} | |
- name: Setup Rust | |
run: rustup show | |
- uses: actions-rs/[email protected] | |
with: | |
crate: bindgen | |
version: latest | |
- uses: maxim-lobanov/setup-xcode@v1 | |
if: runner.os == 'macOS' | |
with: | |
xcode-version: latest-stable | |
- name: Setup bazel | |
uses: jwlawson/actions-setup-bazel@v1 | |
with: | |
bazel-version: '3.7.2' | |
- uses: actions/setup-python@v2 | |
if: runner.os == 'macOS' | |
with: | |
python-version: '3.6' | |
- name: Install Build Dependencies | |
run: | | |
pip install numpy | |
pip3 install numpy | |
- name: Build | |
run: cargo xtask dist | |
env: | |
RUST_LOG: info,xtask=debug | |
- name: Upload binaries to release | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ matrix.asset_name }} | |
path: ${{ matrix.artifact_name }} | |
docker: | |
name: Publish Docker Image | |
runs-on: ubuntu-latest | |
needs: | |
- check_date | |
if: ${{ needs.check_date.outputs.should_run != 'false' }} | |
env: | |
ORGANISATION: tinyverseml | |
REPO: rune-cli | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setting the container and tag variables | |
run: | | |
echo "CONTAINER=${{ env.ORGANISATION }}/${{ env.REPO }}" >> $GITHUB_ENV | |
event_name=${{ github.event_name }} | |
if [ $event_name = "schedule" ] || [ $event_name = "workflow_dispatch" ]; then | |
echo "TAG=nightly" >> $GITHUB_ENV | |
else | |
echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV | |
fi | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
push: ${{ github.ref == 'refs/heads/master' }} | |
tags: | | |
${{ env.CONTAINER }}:latest | |
${{ env.CONTAINER }}:${{ env.TAG }} | |
${{ env.CONTAINER }}:${{ github.sha }} | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
create-release: | |
name: Create Nightly Release | |
runs-on: ubuntu-18.04 | |
needs: | |
- check_date | |
- build | |
if: ${{ needs.check_date.outputs.should_run != 'false' }} | |
steps: | |
- name: Tagged Release Variables | |
if: contains(github.ref, 'refs/tags/') | |
run: | | |
tag=$(basename ${{ github.ref }}) | |
echo "title=Released $tag" >> $GITHUB_ENV | |
echo "tag=$tag" >> $GITHUB_ENV | |
- name: Nightly Release Variables | |
if: ${{ !contains(github.ref, 'refs/tags/') }} | |
run: | | |
echo "title=Nightly Release" >> $GITHUB_ENV | |
echo "tag=nightly" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Fetch Pre-Compiled Binaries | |
uses: actions/download-artifact@v2 | |
with: | |
path: releases | |
- name: Move all up | |
run: mv releases/**/* releases/ | |
- name: Print Artifacts | |
run: ls -la releases | |
- uses: "marvinpinto/action-automatic-releases@latest" | |
if: github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/') | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: ${{ env.tag }} | |
draft: ${{ contains(github.ref, 'refs/tags/') }} | |
prerelease: ${{ !contains(github.ref, 'refs/tags/') }} | |
title: ${{ env.title }} | |
files: | | |
releases/*.zip | |
releases/*.whl |