This repository has been archived by the owner on Jun 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
249 lines (224 loc) · 9.19 KB
/
sqldb-postgres.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: SQLDB_POSTGRES
on:
push:
branches: [main]
paths:
- "sqldb-postgres/**"
tags:
- "sqldb-postgres-v*"
pull_request:
branches: [main]
paths:
- "sqldb-postgres/**"
workflow_dispatch:
inputs:
release:
description: "Build github release (enter y)"
default: "n"
required: true
artifact:
description: "Build github release and push artifact (enter y)"
default: "n"
required: true
env:
CARGO_TERM_COLOR: always
working-directory: ./sqldb-postgres
WASH_ISSUER_KEY: ${{ secrets.WASMCLOUD_ACCOUNT_OFFICIAL }}
WASH_SUBJECT_KEY: ${{ secrets.WASMCLOUD_SQLDB_POSTGRES }}
oci-repository: sqldb-postgres
jobs:
rust_check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- id: rust-check-action
uses: wasmcloud/common-actions/rust-check@main
with:
working-directory: ${{ env.working-directory }}
# disable testing with "cargo test" since this will run 'make test'
test-options: --no-run
make_test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- id: run-nats
uses: wasmcloud/common-actions/run-nats@main
- name: Run tests via Makefile
run: make test
shell: bash
working-directory: ${{ env.working-directory }}
build_artifact:
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
strategy:
fail-fast: false
matrix:
config:
# NOTE: We are building on an older version of ubuntu because of libc compatibility
# issues. Namely, if we build on a new version of libc, it isn't backwards compatible with
# old versions. But if we build on the old version, it is compatible with the newer
# versions running in ubuntu 22 and its ilk
- {
os: "ubuntu-20.04",
arch: "amd64",
extension: "",
targetPath: "target/release/",
}
- {
os: "ubuntu-20.04",
arch: "aarch64",
extension: "",
targetPath: "target/aarch64-unknown-linux-gnu/release/",
}
- {
os: "macos-latest",
arch: "amd64",
extension: "",
targetPath: "target/release/",
}
- {
os: "windows-latest",
arch: "amd64",
extension: ".exe",
targetPath: "target/release/",
}
- {
os: "macos-latest",
arch: "aarch64",
extension: "",
targetPath: "target/aarch64-apple-darwin/release/",
}
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v3
- name: lowercase the runner OS name
shell: bash
run: |
OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
echo "RUNNER_OS=$OS" >> $GITHUB_ENV
- name: Install latest Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
if: matrix.config.arch != 'aarch64'
with:
toolchain: stable
components: clippy, rustfmt
- name: setup for cross-compile builds
if: matrix.config.arch == 'aarch64' && matrix.config.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
rustup toolchain install stable-aarch64-unknown-linux-gnu
rustup target add --toolchain stable-aarch64-unknown-linux-gnu aarch64-unknown-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
- name: Install latest Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
if: matrix.config.arch == 'aarch64' && matrix.config.os == 'macos-latest'
with:
toolchain: stable
components: clippy, rustfmt
target: aarch64-apple-darwin
- name: Install latest Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
if: matrix.config.arch == 'aarch64' && matrix.config.os == 'ubuntu-20.04'
with:
toolchain: stable
components: clippy, rustfmt
target: aarch64-unknown-linux-gnu
- name: build release
working-directory: ${{ env.working-directory }}
if: matrix.config.arch != 'aarch64'
run: "cargo build --release"
- name: build release
working-directory: ${{ env.working-directory }}
if: matrix.config.arch == 'aarch64' && matrix.config.os == 'macos-latest'
run: "cargo build --release --target aarch64-apple-darwin"
- name: build release
working-directory: ${{ env.working-directory }}
if: matrix.config.arch == 'aarch64' && matrix.config.os == 'ubuntu-20.04'
run: "cargo build --release --target aarch64-unknown-linux-gnu"
- name: Determine artifact name
shell: bash
run: |
echo "artifact-name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].targets[0].name')" >> $GITHUB_ENV
working-directory: ${{ env.working-directory }}
- uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact-name }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}
if-no-files-found: error
path: |
${{ env.working-directory }}/${{ matrix.config.targetPath }}${{ env.artifact-name }}${{ matrix.config.extension }}
assemble_provider_archive:
needs: [rust_check, build_artifact]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: wasmcloud/common-actions/install-wash@main
# Downloads all artifacts
- uses: actions/download-artifact@v3
with:
path: ${{ env.working-directory }}
- name: Determine artifact name
run: |
echo "artifact-name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].targets[0].name')" >> $GITHUB_ENV
working-directory: ${{ env.working-directory }}
- name: Create provider archive
working-directory: ${{ env.working-directory }}
run: |
mkdir -p target/release
mv ${{ env.artifact-name }}-linux-amd64/${{ env.artifact-name }} target/release/
make par
- name: Insert provider archive targets
working-directory: ${{ env.working-directory }}
run: |
wash par insert --arch x86_64-macos --binary ${{ env.artifact-name }}-macos-amd64/${{ env.artifact-name }} build/${{ env.artifact-name }}.par.gz
wash par insert --arch aarch64-linux --binary ${{ env.artifact-name }}-linux-aarch64/${{ env.artifact-name }} build/${{ env.artifact-name }}.par.gz
wash par insert --arch aarch64-macos --binary ${{ env.artifact-name }}-macos-aarch64/${{ env.artifact-name }} build/${{ env.artifact-name }}.par.gz
wash par insert --arch x86_64-windows --binary ${{ env.artifact-name }}-windows-amd64/${{ env.artifact-name }}.exe build/${{ env.artifact-name }}.par.gz
- name: Upload provider archive to GH Actions
uses: actions/upload-artifact@v2
with:
name: provider-archive
path: ${{ env.working-directory }}/build/${{ env.artifact-name }}.par.gz
github_release:
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
needs: [rust_check, assemble_provider_archive]
runs-on: ubuntu-20.04
steps:
- name: Download provider archive
uses: actions/download-artifact@v3
with:
name: provider-archive
path: ${{ env.working-directory }}/build
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.working-directory }}/build/*.par.gz
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
draft: false
artifact_release:
needs: [rust_check, assemble_provider_archive]
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Download provider archive
uses: actions/download-artifact@v3
with:
name: provider-archive
path: ${{ env.working-directory }}/build
- name: Determine artifact metadata
run: |
echo "oci-repository=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].name' | sed 's/wasmcloud-provider-//')" >> $GITHUB_ENV
echo "oci-version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].version')" >> $GITHUB_ENV
working-directory: ${{ env.working-directory }}
- name: Push provider archive to AzureCR
uses: wasmcloud/common-actions/oci-artifact-release@main
with:
artifact-path: ${{ env.working-directory }}/build/${{ env.oci-repository }}.par.gz
oci-url: ${{ secrets.AZURECR_PUSH_URL }}
oci-repository: ${{ env.oci-repository }}
oci-version: ${{ env.oci-version }}
oci-username: ${{ secrets.AZURECR_PUSH_USER }}
oci-password: ${{ secrets.AZURECR_PUSH_PASSWORD }}