-
Notifications
You must be signed in to change notification settings - Fork 15
184 lines (175 loc) · 5.9 KB
/
releases.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
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/install@v0.1
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