-
Notifications
You must be signed in to change notification settings - Fork 3
170 lines (163 loc) · 5.81 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
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
name: Release
on:
push:
branches:
- main
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: build release assets
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- {
os: "ubuntu-latest",
arch: "x86_64",
extension: "",
extraArgs: "",
target: "",
targetDir: "target/release",
}
- {
os: "ubuntu-latest",
arch: "aarch64",
extension: "",
extraArgs: "--target aarch64-unknown-linux-gnu",
target: "aarch64-unknown-linux-gnu",
targetDir: "target/aarch64-unknown-linux-gnu/release",
}
- {
os: "macos-latest",
arch: "x86_64",
extension: "",
extraArgs: "",
target: "",
targetDir: "target/release",
}
- {
os: "macos-latest",
arch: "aarch64",
extension: "",
extraArgs: "--target aarch64-apple-darwin",
target: "aarch64-apple-darwin",
targetDir: "target/aarch64-apple-darwin/release/",
}
- {
os: "windows-latest",
arch: "x86_64",
extension: ".exe",
extraArgs: "",
target: "",
targetDir: "target/release",
}
steps:
- uses: actions/checkout@v3
- name: set the release version (tag)
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: set the release version (nightly)
if: github.ref == 'refs/heads/main'
shell: bash
run: echo "RELEASE_VERSION=nightly" >> $GITHUB_ENV
- name: lowercase the runner OS name
shell: bash
run: |
OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
echo "RUNNER_OS=$OS" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
target: ${{ matrix.config.target }}
- name: setup for cross-compiled linux aarch64 build
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt update
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu xz-utils
echo '[target.aarch64-unknown-linux-gnu]' >> ${HOME}/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ${HOME}/.cargo/config.toml
- name: build land-cli
shell: bash
run: |
./deploy/build-cli.sh ${{ matrix.config.arch }} ${{ env.RELEASE_VERSION }} "${{ matrix.config.targetDir }}" "${{ matrix.config.extraArgs }}"
- name: upload binary as GitHub artifact
if: runner.os != 'Windows'
uses: actions/upload-artifact@v3
with:
name: land-cli
path: _dist/land-cli-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz
- name: upload binary as GitHub artifact for windows
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: land-cli
path: _dist/land-cli-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.zip
- name: upload binary to Github release
if: startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _dist/land-cli-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz
tag: ${{ github.ref }}
- name: upload binary to Github release for windows
if: startsWith(github.ref, 'refs/tags/v') && runner.os == 'Windows'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _dist/land-cli-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.zip
tag: ${{ github.ref }}
update-nightly:
name: update nightly release
runs-on: ubuntu-latest
needs:
- build
if: github.ref == 'refs/heads/main'
steps:
- name: Download release assets
uses: actions/download-artifact@v3
with:
name: land-cli
- name: Delete nightly tag
uses: dev-drprasad/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
delete_release: true
- name: Recreate nightly tag and release
uses: rajatjindal/[email protected]
with:
tag: nightly
allowUpdates: true
prerelease: true
artifacts: "land-cli-nightly*"
commit: ${{ github.sha }}
body: |
This is a "nightly" release of land-cli. It is automatically built from the latest commit on the main branch. It includes some new features and bug fixes that have not yet been released. Be careful when using this version of land-cli as it may be unstable.
publish-crates-io:
name: publish crates.io
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: build
steps:
- uses: actions/checkout@v3
- name: Update local toolchain
run: |
rustup update stable
- name: Publish land-sdk-macro
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -p land-sdk-macro
- name: Publish land-sdk
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -p land-sdk