-
Notifications
You must be signed in to change notification settings - Fork 5
178 lines (152 loc) · 6.06 KB
/
net-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
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
171
172
173
174
175
176
177
178
name: '[net] Release'
on:
push:
tags:
- 'net/v*-pin'
jobs:
prepare:
name: Prepare Release
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
shell: bash
outputs:
r_version: ${{ steps.release_info.outputs.version }}
r_tag: rs/v${{ steps.release_info.outputs.version }}
steps:
- name: Extract Release Info
id: release_info
run: |
PIN_TAG=${GITHUB_REF#refs/tags/}
VERSION=${PIN_TAG#net/v}
VERSION="${VERSION%-pin}"
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?$ ]]; then
echo "'$VERSION' is not a valid semver version"
exit 1
fi
echo "Pin Tag: $PIN_TAG"
echo "pin_tag=$PIN_TAG" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
build_win_x64:
name: Build Native Libraries for Win x64
needs: prepare
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Build & Test Client Generator
run: |
cargo build --locked --manifest-path net/rs/Cargo.toml --release
cargo test --locked --manifest-path net/rs/Cargo.toml --release
mkdir -p ./net/rs/target/artifacts/win-x64
cp ./net/rs/target/release/sails_net_client_gen.dll ./net/rs/target/artifacts/win-x64
- name: Upload Client Generator Artifacts
uses: actions/upload-artifact@v4
with:
name: native_client_gen_win_x64
path: ./net/rs/target/artifacts
build_linux_x64:
name: Build Native Libraries for Linux x64
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Build & Test Client Generator
run: |
cargo build --locked --manifest-path net/rs/Cargo.toml --release
cargo test --locked --manifest-path net/rs/Cargo.toml --release
mkdir -p ./net/rs/target/artifacts/linux-x64
cp ./net/rs/target/release/libsails_net_client_gen.so ./net/rs/target/artifacts/linux-x64
- name: Upload Client Generator Artifacts
uses: actions/upload-artifact@v4
with:
name: native_client_gen_linux_x64
path: ./net/rs/target/artifacts
build_osx_x64:
name: Build Native Libraries for NacOS x64
needs: prepare
runs-on: macos-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Build & Test Client Generator
run: |
rustup target add x86_64-apple-darwin
cargo build --locked --manifest-path net/rs/Cargo.toml --release --target x86_64-apple-darwin
cargo test --locked --manifest-path net/rs/Cargo.toml --release --target x86_64-apple-darwin
mkdir -p ./net/rs/target/artifacts/osx-x64
cp ./net/rs/target/x86_64-apple-darwin/release/libsails_net_client_gen.dylib ./net/rs/target/artifacts/osx-x64
- name: Upload Client Generator Artifacts
uses: actions/upload-artifact@v4
with:
name: native_client_gen_osx_x64
path: ./net/rs/target/artifacts
build_osx_arm64:
name: Build Native Libraries for MacOS ARM64
needs: prepare
runs-on: macos-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Build & Test Client Generator
run: |
rustup target add aarch64-apple-darwin
cargo build --locked --manifest-path net/rs/Cargo.toml --release --target aarch64-apple-darwin
cargo test --locked --manifest-path net/rs/Cargo.toml --release --target aarch64-apple-darwin
mkdir -p ./net/rs/target/artifacts/osx-arm64
cp ./net/rs/target/aarch64-apple-darwin/release/libsails_net_client_gen.dylib ./net/rs/target/artifacts/osx-arm64
- name: Upload Client Generator Artifacts
uses: actions/upload-artifact@v4
with:
name: native_client_gen_osx_arm64
path: ./net/rs/target/artifacts
publish:
name: Publish NuGet Packages
needs:
- prepare
- build_win_x64
- build_linux_x64
- build_osx_x64
- build_osx_arm64
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Download Native Libraries
uses: actions/download-artifact@v4
with:
path: native_client_gens
pattern: native_client_gen_*
merge-multiple: true
- name: Build Solution
run: |
dotnet build --configuration Release -p:LibraryRoot=${{ github.workspace }}/native_client_gens
- name: Test Solution
run: |
dotnet test --no-build --configuration Release --logger "trx;LogFileName=TestResults.trx"
- name: Pack NuGet Packages
run: |
dotnet pack ./net/src/Sails.Net/Sails.Net.csproj --no-build --configuration Release --output ./nugets \
-p:Version=${{ needs.prepare.outputs.r_version }} \
-p:PackageVersion=${{ needs.prepare.outputs.r_version }} \
-p:RepositoryUrl=${{ github.server_url }}/${{ github.repository }} \
-p:Authors=Gear
dotnet pack ./net/src/Sails.ClientGenerator/Sails.ClientGenerator.csproj --no-build --configuration Release --output ./nugets \
-p:Version=${{ needs.prepare.outputs.r_version }} \
-p:PackageVersion=${{ needs.prepare.outputs.r_version }} \
-p:RepositoryUrl=${{ github.server_url }}/${{ github.repository }} \
-p:Authors=Gear
- name: Publish NuGet Packages
run: |
NUGET_SOURCE_URL="https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
dotnet nuget add source $NUGET_SOURCE_URL \
--name ${{ github.repository_owner }}-github \
--username "${{ github.workflow }}" \
--password ${{ secrets.GITHUB_TOKEN }} \
--store-password-in-clear-text
dotnet nuget push ./nugets/*.nupkg \
--source $NUGET_SOURCE_URL