-
Notifications
You must be signed in to change notification settings - Fork 86
157 lines (118 loc) · 3.98 KB
/
rust-cli-publish.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
name: Rust CLI Publish
on:
push:
branches:
- "master"
- "next"
paths:
- 'zowex/**'
- '.github/workflows/rust-cli*.yml'
permissions:
contents: write
jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
outputs:
ZOWEX_VERSION: ${{ steps.get-version.outputs.ZOWEX_VERSION }}
steps:
- uses: actions/checkout@v4
- name: Get version
id: get-version
working-directory: zowex
run: echo "ZOWEX_VERSION=$(cargo metadata --no-deps | jq -r .packages[0].version)" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create \
-n "Native Zowe CLI client which communicates with a 'daemon' version of Zowe CLI." \
-t "Native Client Release ${{ steps.get-version.outputs.ZOWEX_VERSION }}" \
native-v${{ steps.get-version.outputs.ZOWEX_VERSION }}
- uses: actions/upload-artifact@v4
with:
name: repo
path: |
zowex/**
!.git
build-linux:
name: Build Linux
needs: release
runs-on: ubuntu-latest
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: actions/download-artifact@v4
with:
name: repo
- name: Prepare Cross
run: cargo install cross@0.2.5
# Need to build in container with old version of GLIBC to support RHEL 7
# https://kobzol.github.io/rust/ci/2021/05/07/building-rust-binaries-in-ci-that-work-with-older-glibc.html
- name: Build
run: cross build --verbose --release
- name: Create Archive
run: |
cd target/x86_64-unknown-linux-gnu/release
tar -cvzf zowe.tgz zowe
mv zowe.tgz zowe-linux.tgz
- name: Upload Release Asset
id: upload-release-asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload native-v${{ needs.release.outputs.ZOWEX_VERSION }} target/x86_64-unknown-linux-gnu/release/zowe-linux.tgz --repo ${{ github.repository }}
build-macos:
name: Build MacOS
needs: release
runs-on: macos-latest
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-apple-darwin
- uses: actions/download-artifact@v4
with:
name: repo
- name: Build
run: |
cargo build --verbose --release --target aarch64-apple-darwin
cargo build --verbose --release --target x86_64-apple-darwin
mkdir -p target/release && cd target/release
mv ../aarch64-apple-darwin/release/zowe zowe.aarch64 && mv ../x86_64-apple-darwin/release/zowe zowe.x86_64
lipo -create -output zowe zowe.aarch64 zowe.x86_64
# Use gtar instead of tar on MacOS to prevent extra `GNUSparseFile.0` directory
- name: Create Archive
run: |
cd target/release
gtar -cvzf zowe.tgz zowe
mv zowe.tgz zowe-macos.tgz
- name: Upload Release Asset
id: upload-release-asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload native-v${{ needs.release.outputs.ZOWEX_VERSION }} target/release/zowe-macos.tgz --repo ${{ github.repository }}
build-windows:
name: Build Windows
needs: release
runs-on: windows-latest
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: actions/download-artifact@v4
with:
name: repo
- name: Build
run: cargo build --verbose --release
env:
RUSTFLAGS: "-Ctarget-feature=+crt-static"
- name: Create Archive
run: |
cd target/release
tar -cvzf zowe.tgz zowe.exe
mv zowe.tgz zowe-windows.tgz
- name: Upload Release Asset
id: upload-release-asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload native-v${{ needs.release.outputs.ZOWEX_VERSION }} target/release/zowe-windows.tgz --repo ${{ github.repository }}