-
Notifications
You must be signed in to change notification settings - Fork 36
202 lines (187 loc) · 6.74 KB
/
tembo_release.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Github release for the repo
permissions:
contents: write
on:
push:
branches:
- release-notes
paths:
- 'tembo-cli/Cargo.toml'
jobs:
pre_gh_release:
runs-on: macos-latest
outputs:
release_version: ${{ steps.set_release_version.outputs.release_version }}
steps:
- name: set release version
id: set_release_version
run: |
RELEASE_VERSION=$(date +'%Y.%m.%d')
echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
echo "TEMBO_RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Create Github release
shell: bash
env:
GH_TOKEN: ${{ secrets.SERVICE_USER_GITHUB_SSH_KEY }}
run: |
gh release create "$TEMBO_RELEASE_VERSION" \
--repo="[email protected]:tembo-io/tembo.git" \
--title="$TEMBO_RELEASE_VERSION" \
--generate-notes --prerelease
gh_release:
name: Github Release
needs: pre_gh_release
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
asset_name: x86_64-apple
os: macos-latest
executable: tembo
- target: aarch64-apple-darwin
asset_name: aarch64-apple
os: macos-latest
executable: tembo
- target: x86_64-unknown-linux-musl
asset_name: x86_64-linux
os: ubuntu-20.04
container: quay.io/tembo/muslrust:1.76.0-stable
executable: tembo
- target: aarch64-unknown-linux-musl
asset_name: aarch64-linux
os: ubuntu-20.04
container: messense/rust-musl-cross:aarch64-musl
executable: tembo
- target: x86_64-pc-windows-msvc
asset_name: x86_64-windows
os: windows-latest
executable: tembo.exe
runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.cli_version_mac.outputs.version }}
sha_x86_64: ${{ steps.fetch_sha256.outputs.sha_x86_64 }}
sha_aarch64: ${{ steps.fetch_sha256.outputs.sha_aarch64 }}
container:
image: ${{ matrix.container }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Install Deps Ubuntu
id: install_deps_ubuntu
run: |
set -x
apt update -y
apt install pkg-config libssl-dev -y
if: runner.os == 'Linux'
- name: Cargo build
working-directory: ./tembo-cli
id: cargo_build
run: |
rustup target add ${{ matrix.target }}
cargo build --release --target=${{ matrix.target }}
cd target/${{ matrix.target }}/release
tar -czvf tembo.tar.gz ${{ matrix.executable }}
git config --global --add safe.directory '*'
- name: Fetch sha256
working-directory: ./tembo-cli
id: fetch_sha256
run: |
sha_256=$(shasum -a 256 target/${{ matrix.target }}/release/tembo.tar.gz | cut -d" " -f 1)
if [[ ${{ matrix.target }} == "x86_64-apple-darwin" ]]
then
echo "sha_x86_64=$sha_256" >> $GITHUB_OUTPUT
elif [[ ${{ matrix.target }} == "aarch64-apple-darwin" ]]
then
echo "sha_aarch64=$sha_256" >> $GITHUB_OUTPUT
fi
if: runner.os == 'macOS'
# TODO: Figure out a better way to fetch version for mac & linux
- name: CLI version Mac
working-directory: ./tembo-cli
id: cli_version_mac
run: |
cargo install cargo-get
VERSION=$(cargo-get package.version)
TEMBO_CLI_NAME=$(cargo-get package.name)-$VERSION
echo "TEMBO_CLI_NAME=$TEMBO_CLI_NAME" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
if: runner.os == 'macOS'
- name: CLI version Linux
working-directory: ./tembo-cli
id: cli_version_linux
run: |
set -x
PKG_VERSION=$(awk -F ' = ' '$$1 ~ /version/ { gsub(/[\\"]/, "", $$2); printf("%s",$$2); exit; }' Cargo.toml)
TEMBO_VERSION=${PKG_VERSION#"version = "}
TEMBO_CLI_NAME=tembo-cli-${TEMBO_VERSION}
echo "TEMBO_CLI_NAME=$TEMBO_CLI_NAME" >> $GITHUB_ENV
if: runner.os == 'Linux'
- name: CLI version Windows
working-directory: ./tembo-cli
id: cli_version_windows
run: |
$TEMBO_VERSION = $(target/${{ matrix.target }}/release/tembo.exe --version)
$TEMBO_CLI_NAME = $TEMBO_VERSION.replace(' ','-')
echo "TEMBO_CLI_NAME=$TEMBO_CLI_NAME" >> $env:GITHUB_ENV
if: runner.os == 'Windows'
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: tembo-cli/target/${{ matrix.target }}/release/tembo.tar.gz
asset_name: ${{ env.TEMBO_CLI_NAME }}-${{ matrix.asset_name }}.tar.gz
tag: ${{ env.RELEASE_TAG }}
body: ${{ steps.changelog.outputs.changelog }}
post_gh_release:
runs-on: macos-latest
needs: gh_release
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
repository: tembo-io/homebrew-tembo
ssh-key: ${{ secrets.SERVICE_USER_GITHUB_SSH_KEY }}
path: homebrew-tembo
- name: Git commit and push to remote
shell: bash
run: |
set -xe
cd homebrew-tembo
git config --global user.name "coredb-service-user"
git config --global user.email "[email protected]"
git fetch origin main && git checkout main
- name: Replace version
shell: bash
run: |
set -xe
cd homebrew-tembo
sed -E -i '' 's/version ".*/version "${{needs.gh_release.outputs.version}}"/g' tembo-cli.rb
- name: Replace release_version
shell: bash
run: |
set -xe
cd homebrew-tembo
sed -E -i '' 's/release_version =.*/release_version = "${{needs.pre_gh_release.outputs.release_version}}"/g' tembo-cli.rb
- name: Replace sha_x86_64
shell: bash
run: |
set -xe
cd homebrew-tembo
sed -E -i '' 's/sha256.*/sha256 "${{needs.gh_release.outputs.sha_x86_64}}"/g' tembo-cli.rb
- name: Replace sha_aarch_64
shell: bash
run: |
set -xe
cd homebrew-tembo
sed -E -i '' '1,/sha256.*/ s/sha256.*/sha256 "${{needs.gh_release.outputs.sha_aarch64}}"/g' tembo-cli.rb
- name: Git commit and push to remote
shell: bash
run: |
set -xe
cd homebrew-tembo
git add --all
# debugging
git diff HEAD
git commit -m "Update from tembo-io/tembo: ${{needs.gh_release.outputs.version}}"
git push origin main