Skip to content

Commit 33ce400

Browse files
authored
Merge pull request #99 from supabase/feat/release-cli
Add action to release `dbdev` CLI
2 parents 066da1c + 17eea95 commit 33ce400

1 file changed

Lines changed: 138 additions & 0 deletions

File tree

.github/workflows/release-cli.yaml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Release CLI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
create-release:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
- name: Create Release
16+
id: create_release
17+
uses: actions/create-release@v1
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
tag_name: ${{ github.ref }}
22+
release_name: ${{ github.ref }}
23+
body: |
24+
TODO: Write release notes
25+
draft: false
26+
prerelease: false
27+
28+
build-linux:
29+
name: Release Artifacts on Linux
30+
needs:
31+
- create-release
32+
strategy:
33+
matrix:
34+
box:
35+
- { runner: ubuntu-20.04, os-and-arch: linux-amd64 }
36+
- { runner: arm-runner, os-and-arch: linux-arm64 }
37+
runs-on: ${{ matrix.box.runner }}
38+
timeout-minutes: 45
39+
steps:
40+
- name: Install dependencies
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install -y --no-install-recommends curl build-essential libssl-dev pkg-config
44+
45+
- name: Install Rust Toolchain
46+
uses: actions-rs/toolchain@v1
47+
with:
48+
profile: minimal
49+
toolchain: stable
50+
51+
- uses: actions/checkout@v3
52+
- name: Build and Package
53+
run: |
54+
cd cli
55+
cargo build --release
56+
cd ./target/release && tar -czvf dbdev.tar.gz ./dbdev
57+
58+
- name: Get Upload Url
59+
run: echo UPLOAD_URL=$(curl --silent https://api.github.com/repos/${{ github.repository }}/releases/latest | jq .upload_url --raw-output) >> $GITHUB_ENV
60+
61+
- name: Upload Release Asset
62+
uses: actions/upload-release-asset@v1
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
with:
66+
upload_url: ${{ env.UPLOAD_URL }}
67+
asset_path: ./cli/target/release/dbdev.tar.gz
68+
asset_name: dbdev-${{ github.ref_name }}-${{ matrix.box.os-and-arch }}.tar.gz
69+
asset_content_type: application/gzip
70+
71+
build-macos:
72+
name: Release Artifacts on macOS
73+
needs:
74+
- create-release
75+
runs-on: macos-12
76+
timeout-minutes: 45
77+
steps:
78+
- name: Install Rust Toolchain
79+
uses: actions-rs/toolchain@v1
80+
with:
81+
profile: minimal
82+
toolchain: stable
83+
84+
- uses: actions/checkout@v3
85+
- name: Build and Package on Unix
86+
run: |
87+
cd cli
88+
cargo build --release
89+
cd ./target/release && tar -czvf dbdev.tar.gz ./dbdev
90+
91+
- name: Get Upload Url
92+
run: echo UPLOAD_URL=$(curl --silent https://api.github.com/repos/${{ github.repository }}/releases/latest | jq .upload_url --raw-output) >> $GITHUB_ENV
93+
94+
- name: Upload Release Asset
95+
uses: actions/upload-release-asset@v1
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
with:
99+
upload_url: ${{ env.UPLOAD_URL }}
100+
asset_path: ./cli/target/release/dbdev.tar.gz
101+
asset_name: dbdev-${{ github.ref_name }}-macos-amd64.tar.gz
102+
asset_content_type: application/${{ matrix.box.content-type }}
103+
104+
build-windows:
105+
name: Release Artifacts on Windows
106+
needs:
107+
- create-release
108+
runs-on: windows-2022
109+
timeout-minutes: 45
110+
steps:
111+
- name: Install Rust Toolchain
112+
uses: actions-rs/toolchain@v1
113+
with:
114+
profile: minimal
115+
toolchain: stable
116+
117+
- uses: actions/checkout@v3
118+
- name: Build and Package on Windows
119+
run: |
120+
cd cli
121+
cargo build --release
122+
cd ./target/release && Compress-Archive -Path ./dbdev.exe -Destination dbdev.zip
123+
124+
- name: Get Upload Url
125+
run: |
126+
$Json = Invoke-WebRequest -Uri https://api.github.com/repos/${{ github.repository }}/releases/latest | ConvertFrom-Json
127+
$UploadUrl = $Json.upload_url
128+
echo "UPLOAD_URL=$UploadUrl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
129+
130+
- name: Upload Release Asset
131+
uses: actions/upload-release-asset@v1
132+
env:
133+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
with:
135+
upload_url: ${{ env.UPLOAD_URL }}
136+
asset_path: ./cli/target/release/dbdev.zip
137+
asset_name: dbdev-${{ github.ref_name }}-windows-amd64.zip
138+
asset_content_type: application/zip

0 commit comments

Comments
 (0)