-
Notifications
You must be signed in to change notification settings - Fork 17
59 lines (52 loc) · 1.88 KB
/
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
name: Release Workflow
on:
release:
types: [created, published]
jobs:
build-and-release:
permissions:
contents: write
runs-on: ubuntu-22.04
if: >
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'release' && github.event.action == 'created')
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Cache Cargo Registry and Build Output
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Install Rust toolchain
run: |
rustup update stable
rustup default stable
- name: Build release binary
run: |
cargo build --release --verbose
strip target/release/near-lake
cp target/release/near-lake near-lake
- name: Determine UPLOAD_URL
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
RELEASE_RESPONSE=$(curl -s -X GET -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG_NAME")
UPLOAD_URL=$(echo "$RELEASE_RESPONSE" | jq -r .upload_url)
echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV
else
echo "UPLOAD_URL=${{ github.event.release.upload_url }}" >> $GITHUB_ENV
fi
- name: Upload release asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: ./near-lake
asset_name: near-lake
asset_content_type: application/octet-stream