forked from coral-xyz/anchor
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (78 loc) · 2.34 KB
/
release.yaml
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
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
# TODO: Remove
branches:
- ci-upload-binaries-to-releases
pull_request:
branches:
- master
paths:
- VERSION
env:
is_tag: startsWith(github.ref, 'refs/tags/')
# dist: dist-${{ github.ref_name }}
dist: dist-v0.0.0
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
target:
# - aarch64-apple-darwin
- x86_64-unknown-linux-gnu
# - x86_64-apple-darwin
# - x86_64-pc-windows-msvc
include:
# - target: aarch64-apple-darwin
# os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
# - target: x86_64-apple-darwin
# os: macos-latest
# - target: x86_64-pc-windows-msvc
# os: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Build release binary
run: cargo build --package anchor-cli --release --locked --target ${{ matrix.target }}
- name: Prepare
# if: env.is_tag
id: prepare
shell: bash
run: |
version=$(echo v0.0.0 | cut -dv -f2)
mkdir -p $dist
ext=""
[[ "${{ matrix.os }}" == windows-latest ]] && ext=".exe"
mv "target/${{ matrix.target }}/release/anchor$ext" $dist/anchor$ext-$version-${{ matrix.target }}
echo "version=$version" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
# if: env.is_tag
with:
name: anchor-${{ steps.prepare.outputs.version }}-${{ matrix.target }}
path: ${{ env.dist }}
overwrite: true
retention-days: 1
upload:
name: Upload binaries to release
# if: startsWith(github.ref, 'refs/tags/') # `env.is_tag` doesn't work for some reason
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: ${{ env.dist }}
- name: Upload
shell: bash
run: GH_TOKEN=${{ secrets.GITHUB_TOKEN }} gh release upload "v0.0.0" $dist/*/* --clobber