forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (165 loc) · 8 KB
/
gradle-cd.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
name: Continuous Deployment
env:
MATRIX: '[{"OS": "ubuntu","NAMED_OS": "linux","RUNNER": "ubuntu-latest","ARCH": "x64","TARGET": "x86_64-unknown-linux-gnu","CLASSIFIER": "linux-x86_64"},
{"OS": "ubuntu","NAMED_OS": "linux","RUNNER": ["self-hosted", "Linux", "ARM64"],"ARCH": "arm64","TARGET": "aarch64-unknown-linux-gnu","CLASSIFIER": "linux-aarch_64"},
{"OS": "macos","NAMED_OS": "darwin","RUNNER": "macos-12","ARCH": "x64","TARGET": "x86_64-apple-darwin","CLASSIFIER": "osx-x86_64"},
{"OS": "macos","NAMED_OS": "darwin","RUNNER": "macos-13-xlarge","ARCH": "arm64","TARGET": "aarch64-apple-darwin","CLASSIFIER": "osx-aarch_64"}]'
#,
#{"OS": "ubuntu","NAMED_OS": "linux","ARCH": "arm64","TARGET": "aarch64-unknown-linux-musl","RUNNER": ["self-hosted", "Linux", "ARM64"],"IMAGE": "node:alpine","CONTAINER_OPTIONS": "--user root --privileged --rm"},
#{"OS": "ubuntu","NAMED_OS": "linux","ARCH": "x64","TARGET": "x86_64-unknown-linux-musl","RUNNER": "ubuntu-latest","IMAGE": "node:alpine","CONTAINER_OPTIONS": "--user root --privileged"}]'
on:
pull_request:
paths:
- .github/workflows/gradle-cd.yml
- .github/workflows/start-self-hosted-runner/action.yml
- .github/workflows/install-rust-and-protoc/action.yml
push:
tags:
- "v*.*"
concurrency:
group: npm-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
id-token: write
jobs:
output-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix
id: set-matrix
run: |
echo "::set-output name=matrix::${{toJson( env.MATRIX )}}"
start-self-hosted-runner:
#if: github.repository_owner == 'aws'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Start self hosted EC2 runner
uses: ./.github/workflows/start-self-hosted-runner
with:
role-to-assume: ${{ secrets.ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
ec2-instance-id: ${{ secrets.AWS_EC2_INSTANCE_ID }}
publish-binaries:
needs: [start-self-hosted-runner, output-matrix]
#if: github.repository_owner == 'aws'
name: Publish packages to Maven Central
runs-on: ${{ matrix.build.RUNNER }}
container:
image: ${{ matrix.build.IMAGE || '' }}
options: ${{ matrix.build.CONTAINER_OPTIONS || 'none'}}
strategy:
fail-fast: false
matrix:
build:
${{fromJson(needs.output-matrix.outputs.matrix)}}
steps:
- name: Setup self-hosted runner access
if: ${{ contains(matrix.build.RUNNER, 'self-hosted') && matrix.build.TARGET != 'aarch64-unknown-linux-musl' }}
run: sudo chown -R $USER:$USER /home/ubuntu/actions-runner/_work/glide-for-redis
# For MUSL on X64 we need to install git since we use the checkout action
- name: Install git for musl
if: ${{ contains(matrix.build.TARGET, 'x86_64-unknown-linux-musl')}}
run: |
apk update
apk add git
- name: Checkout
if: ${{ matrix.build.TARGET != 'aarch64-unknown-linux-musl' }}
uses: actions/checkout@v4
with:
submodules: "true"
fetch-depth: 0
#- name: Setup for musl
# if: ${{ contains(matrix.build.TARGET, 'musl')}}
# uses: ./.github/workflows/setup-musl-on-linux
# with:
# workspace: $GITHUB_WORKSPACE
# npm-scope: ${{ vars.NPM_SCOPE }}
# npm-auth-token: ${{ secrets.NPM_AUTH_TOKEN }}
# arch: ${{ matrix.build.ARCH }}
- name: Set the release version
shell: bash
run: |
export version=`if ${{ github.event_name == 'pull_request' }}; then echo '255.255.255'; else echo ${GITHUB_REF:11}; fi`
echo "RELEASE_VERSION=${version}" >> $GITHUB_ENV
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ matrix.java }}
- name: Install shared software dependencies
uses: ./.github/workflows/install-shared-dependencies
with:
os: ${{ matrix.host.OS }}
target: ${{ matrix.host.TARGET }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install protoc (protobuf)
uses: arduino/setup-protoc@v3
with:
version: "26.1"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Update package version in config.toml
uses: ./.github/workflows/update-glide-version
with:
folder_path: "${{ github.workspace }}/java/.cargo"
named_os: ${{ matrix.build.NAMED_OS }}
- name: Create build.gradle file
shell: bash
working-directory: ./java/client
run: |
SED_FOR_MACOS=`if [[ "${{ inputs.os }}" =~ .*"macos".* ]]; then echo "''"; fi`
sed -i $SED_FOR_MACOS 's/placeholder/${{ matrix.build.CLASSIFIER }}/g' ./build.gradle
#- name: Build Java wrapper
# working-directory: java
# run: ./gradlew --continue build
- name: Publish to Maven Central
if: github.event_name != 'pull_request'
shell: bash
working-directory: java
run: |
./gradlew :client:publishToMavenLocal
# set +e
# Redirect only stderr
# { npm_publish_err=$(npm publish --access public 2>&1 >&3 3>&-); } 3>&1
# if [[ "$npm_publish_err" == *"You cannot publish over the previously published versions"* ]]
# then
# echo "Skipping publishing, package already published"
# elif [[ ! -z "$npm_publish_err" ]]
# then
# echo "Failed to publish with error: ${npm_publish_err}"
# exit 1
# fi
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
#- name: Pack the Java JAR
# shell: bash
# working-directory: ./node
# run: |
# # Remove the "cpu" and "os" fileds so the base package would be able to install it on ubuntu
# SED_FOR_MACOS=`if [[ "${{ matrix.build.OS }}" =~ .*"macos".* ]]; then echo "''"; fi`
# sed -i $SED_FOR_MACOS '/"\/\/\/cpu": \[/,/]/d' ./package.json && sed -i $SED_FOR_MACOS '/"\/\/\/os": \[/,/]/d' ./package.json
# mkdir -p bin
# npm pack --pack-destination ./bin
# ls ./bin
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Upload the JAR
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.build.TARGET }}
path: ./java/client/build/libs/glide-placeholder.jar
if-no-files-found: error
# Reset the repository to make sure we get the clean checkout of the action later in other actions.
# It is not required since in other actions we are cleaning before the action, but it is a good practice to do it here as well.
- name: Reset repository
if: ${{ matrix.build.ARCH == 'arm64' }}
shell: bash
run: |
git reset --hard
git clean -xdf