Skip to content

Commit aa58a70

Browse files
siddharthlatestdependabot[bot]github-actions[bot]
authored
Sync latest changes (#388)
* chore: v8.22.2 release * chore: add binary publish flow * chore: add build_images workflow * fix (schema): update create-schema to handle update-schema as well * chore(deps): bump golang.org/x/net from 0.10.0 to 0.23.0 (#383) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.10.0 to 0.23.0. - [Commits](golang/net@v0.10.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix (build): fetch next branch so pushing is possible, trigger by workflow_dispatch * Update schema for latest release * chore(build): updates build image workflow to utilize AWS_HOST - for building both AMI and cluster binary. * fix(build): support major versions >= 8 for Arc release build steps * fix(build): update to valid source ami * fix(build): zip path * fix(workflow): output file names and packer event trigger condition * chore (build): uses sudo for previous build related cleanup --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 7c3b745 commit aa58a70

File tree

18 files changed

+552
-83
lines changed

18 files changed

+552
-83
lines changed
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
name: build binary
2+
on:
3+
release:
4+
types: [published]
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "Version tag to build (e.g., 9.0.0)"
9+
required: true
10+
type: string
11+
12+
jobs:
13+
determine_whether_to_run:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
build_arc: ${{ steps.check-build-arc.outputs.run_jobs }}
17+
version: ${{ steps.get-version.outputs.version }}
18+
19+
steps:
20+
- name: Check if Arc binary should be built
21+
id: check-build-arc
22+
env:
23+
INPUT_VERSION: ${{ inputs.version }}
24+
RELEASE_TAG: ${{ github.event.release.tag_name }}
25+
run: |
26+
TAG_NAME="${INPUT_VERSION:-${RELEASE_TAG}}"
27+
echo "Checking tag $TAG_NAME for ARC build"
28+
if echo "$TAG_NAME" | grep -Eq '^([8-9]|[1-9][0-9]+)\.[0-9]+\.[0-9]+$'; then
29+
echo "run_jobs=true" >> "$GITHUB_OUTPUT"
30+
else
31+
echo "run_jobs=false" >> "$GITHUB_OUTPUT"
32+
fi
33+
34+
- name: Get the version from the tag
35+
id: get-version
36+
env:
37+
INPUT_VERSION: ${{ inputs.version }}
38+
RELEASE_TAG: ${{ github.event.release.tag_name }}
39+
run: |
40+
VERSION="${INPUT_VERSION:-${RELEASE_TAG}}"
41+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
42+
43+
build-arc:
44+
name: Build ARC binary
45+
needs: determine_whether_to_run
46+
if: needs.determine_whether_to_run.outputs.build_arc == 'true'
47+
runs-on: ubuntu-latest
48+
timeout-minutes: 60
49+
steps:
50+
- name: Checkout Repository
51+
uses: actions/checkout@v2
52+
53+
# Build AMI zip on AWS host and upload to this release by tag
54+
- name: building binaries for ami
55+
uses: appleboy/ssh-action@v0.1.7
56+
env:
57+
VERSION: ${{ needs.determine_whether_to_run.outputs.version }}
58+
PAT_ACCESS_TOKEN: ${{ secrets.PAT_ACCESS_TOKEN }}
59+
with:
60+
host: ${{ secrets.AWS_BUILD_HOST }}
61+
username: ${{ secrets.AWS_BUILD_USERNAME }}
62+
key: ${{ secrets.AWS_BUILD_KEY }}
63+
port: 22
64+
envs: VERSION,PAT_ACCESS_TOKEN
65+
script: |
66+
set -euo pipefail
67+
export PATH=$PATH:/usr/local/go/bin:/usr/bin
68+
export GOPATH=$HOME/go
69+
70+
# Write build helper script on the remote host
71+
cat > "$HOME/rs_build.sh" <<'EOS'
72+
#!/usr/bin/env bash
73+
# Usage: rs_build.sh <version> <mode> [branch_or_tag]
74+
# mode: ami | cluster
75+
set -euo pipefail
76+
77+
version="${1:?version required}"
78+
mode="${2:-ami}"
79+
branch="${3:-$version}"
80+
81+
# ----- Token resolution -----
82+
# Use env PAT_ACCESS_TOKEN or ~/.rs_pat if present.
83+
PAT_ACCESS_TOKEN="${PAT_ACCESS_TOKEN:-}"
84+
if [[ -z "${PAT_ACCESS_TOKEN}" && -f "${HOME}/.rs_pat" ]]; then
85+
PAT_ACCESS_TOKEN="$(cat "${HOME}/.rs_pat")"
86+
fi
87+
: "${PAT_ACCESS_TOKEN:?PAT_ACCESS_TOKEN missing (export it or place it in ~/.rs_pat)}"
88+
89+
if [[ "${mode}" != "ami" && "${mode}" != "cluster" ]]; then
90+
echo "mode must be 'ami' or 'cluster'"; exit 1
91+
fi
92+
93+
# ----- Prereqs -----
94+
command -v go >/dev/null || { echo "go not found on builder"; exit 1; }
95+
command -v zip >/dev/null || { echo "zip not found on builder"; exit 1; }
96+
command -v curl >/dev/null || { echo "curl not found on builder"; exit 1; }
97+
command -v git >/dev/null || { echo "git not found on builder"; exit 1; }
98+
99+
export GO111MODULE=on
100+
export CGO_ENABLED=1
101+
export PATH="$PATH:/usr/local/go/bin:/usr/bin"
102+
103+
# ----- Clone & build -----
104+
sudo rm -rf arc-noss build out 2>/dev/null || true
105+
echo "Cloning appbaseio-confidential/rs-api-server @ ${branch}"
106+
git clone --depth=1 -b "${branch}" "https://${PAT_ACCESS_TOKEN}@github.com/appbaseio-confidential/rs-api-server" arc-noss
107+
108+
pushd arc-noss >/dev/null
109+
make clean
110+
if [[ "${mode}" == "ami" ]]; then
111+
BILLING=true CLUSTER_BILLING= VERSION="${version}" make
112+
else
113+
BILLING= CLUSTER_BILLING=true VERSION="${version}" make
114+
fi
115+
popd >/dev/null
116+
117+
mkdir -p out
118+
# Zip without the leading arc-noss/ so the archive has build/ and go/ at root
119+
pushd arc-noss >/dev/null
120+
zip -r "../out/arc-linux-${mode}.zip" build go >/dev/null
121+
popd >/dev/null
122+
echo "Packaged out/arc-linux-${mode}.zip (root: build/, go/)"
123+
124+
# ----- Upload to GitHub release (by tag) -----
125+
owner="appbaseio"
126+
repo="reactivesearch-api"
127+
tag="${version}"
128+
129+
release_json="$(curl -fsSL -H "Authorization: token ${PAT_ACCESS_TOKEN}" \
130+
"https://api.github.com/repos/${owner}/${repo}/releases/tags/${tag}")" || {
131+
echo "Failed to fetch release for tag ${tag}"; exit 1; }
132+
133+
# First id field is the release id
134+
release_id="$(printf '%s' "${release_json}" | awk -F: '/"id":/{gsub(/[ ,]/,"",$2); print $2; exit}')" || true
135+
if [[ -z "${release_id}" ]]; then
136+
echo "Could not parse release id for tag ${tag}"; exit 1
137+
fi
138+
139+
asset_path="out/arc-linux-${mode}.zip"
140+
asset_name="$(basename "${asset_path}")"
141+
upload_url="https://uploads.github.com/repos/${owner}/${repo}/releases/${release_id}/assets?name=${asset_name}"
142+
143+
echo "Uploading ${asset_name} to ${owner}/${repo} (release ${tag})..."
144+
http_code="$(curl -sS -w '%{http_code}' -o /tmp/upload_resp.json \
145+
-X POST -H "Authorization: token ${PAT_ACCESS_TOKEN}" \
146+
-H "Content-Type: application/octet-stream" \
147+
--data-binary @"${asset_path}" \
148+
"${upload_url}")"
149+
150+
if [[ "${http_code}" == "201" ]]; then
151+
echo "Upload successful: ${asset_name}"
152+
elif [[ "${http_code}" == "422" ]]; then
153+
echo "Asset exists; attempting replace…"
154+
if command -v jq >/dev/null 2>&1; then
155+
assets_url="$(printf '%s' "${release_json}" | jq -r '.assets_url')"
156+
assets_json="$(curl -fsSL -H "Authorization: token ${PAT_ACCESS_TOKEN}" "${assets_url}")"
157+
existing_id="$(printf '%s' "${assets_json}" | jq -r ".[] | select(.name==\"${asset_name}\") | .id")" || true
158+
if [[ -n "${existing_id}" && "${existing_id}" != "null" ]]; then
159+
curl -fsSL -X DELETE -H "Authorization: token ${PAT_ACCESS_TOKEN}" \
160+
"https://api.github.com/repos/${owner}/${repo}/releases/assets/${existing_id}" || true
161+
http_code2="$(curl -sS -w '%{http_code}' -o /tmp/upload_resp2.json \
162+
-X POST -H "Authorization: token ${PAT_ACCESS_TOKEN}" \
163+
-H "Content-Type: application/octet-stream" \
164+
--data-binary @"${asset_path}" \
165+
"${upload_url}")"
166+
[[ "${http_code2}" == "201" ]] && echo "Re-upload successful" || { echo "Re-upload failed (${http_code2})"; cat /tmp/upload_resp2.json; exit 1; }
167+
else
168+
echo "Could not find existing asset id to delete."; cat /tmp/upload_resp.json; exit 1
169+
fi
170+
else
171+
echo "jq not available; cannot replace existing asset automatically."; cat /tmp/upload_resp.json; exit 1
172+
fi
173+
else
174+
echo "Upload failed (${http_code})."; cat /tmp/upload_resp.json; exit 1
175+
fi
176+
177+
echo "Done."
178+
EOS
179+
chmod +x "$HOME/rs_build.sh"
180+
181+
# Build AMI artifact first so Packer can fetch it
182+
"$HOME/rs_build.sh" "${VERSION}" ami "${VERSION}"
183+
184+
- name: Build AMI
185+
uses: hashicorp/packer-github-actions@master
186+
with:
187+
command: build
188+
target: "./ami.json"
189+
env:
190+
PACKER_LOG: 1
191+
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
192+
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
193+
VERSION: ${{ needs.determine_whether_to_run.outputs.version }}
194+
195+
# Reuse the same AWS host to build the cluster zip and upload it
196+
- name: building binaries for cluster (linux/amd64)
197+
uses: appleboy/ssh-action@v0.1.7
198+
env:
199+
VERSION: ${{ needs.determine_whether_to_run.outputs.version }}
200+
PAT_ACCESS_TOKEN: ${{ secrets.PAT_ACCESS_TOKEN }}
201+
with:
202+
host: ${{ secrets.AWS_BUILD_HOST }}
203+
username: ${{ secrets.AWS_BUILD_USERNAME }}
204+
key: ${{ secrets.AWS_BUILD_KEY }}
205+
port: 22
206+
envs: VERSION,PAT_ACCESS_TOKEN
207+
script: |
208+
set -euo pipefail
209+
export PATH=$PATH:/usr/local/go/bin:/usr/bin
210+
export GOPATH=$HOME/go
211+
if [[ ! -x "$HOME/rs_build.sh" ]]; then
212+
echo "Missing build helper; abort."; exit 1
213+
fi
214+
"$HOME/rs_build.sh" "${VERSION}" cluster "${VERSION}"
215+
216+
send-packer-event-arc:
217+
name: Send Packer Event
218+
needs: build-arc
219+
uses: ./.github/workflows/build_images.yml
220+
with:
221+
# Pass a tag-style ref so the called workflow's regex gate passes on manual runs
222+
ref: "refs/tags/${{ needs.determine_whether_to_run.outputs.version }}"
223+
event_name: new_release
224+
secrets:
225+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
226+
227+
send-docker-event-arc:
228+
name: Send Docker Event
229+
needs: [build-arc, determine_whether_to_run]
230+
runs-on: ubuntu-latest
231+
steps:
232+
- name: Send repo dispatch
233+
uses: peter-evans/repository-dispatch@v2
234+
with:
235+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
236+
repository: appbaseio-confidential/rs-api-server
237+
event-type: publish_docker
238+
client-payload: '{"version": "${{ needs.determine_whether_to_run.outputs.version }}" }'

.github/workflows/build_images.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Send Build Image Event
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
required: true
8+
type: string
9+
event_name:
10+
required: true
11+
type: string
12+
secrets:
13+
token:
14+
required: true
15+
16+
jobs:
17+
determine_whether_to_run:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
send_event: ${{ steps.check-send-event.outputs.run_jobs }}
21+
22+
steps:
23+
- name: Check if event should be sent
24+
id: check-send-event
25+
run: (echo "${{ inputs.ref }}" | grep -Eq '^refs\/tags\/[0-9]+\.[0-9]+\.[0-9]+$') && echo "::set-output name=run_jobs::true" || echo "::set-output name=run_jobs::false"
26+
27+
send_event:
28+
needs: determine_whether_to_run
29+
runs-on: ubuntu-latest
30+
if: needs.determine_whether_to_run.outputs.send_event == 'true'
31+
32+
steps:
33+
- name: Send Repo Dispatch Event
34+
uses: peter-evans/repository-dispatch@v2
35+
with:
36+
token: ${{ secrets.token }}
37+
repository: appbaseio-confidential/elasticsearch-packer-build
38+
event-type: ${{ inputs.event_name }}
Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,43 @@
11
name: Create Schema for latest release
22

33
on:
4-
repository_dispatch:
5-
types: [create_schema]
4+
release:
5+
types: [published]
66
workflow_dispatch:
77

88
jobs:
9+
determine_whether_to_run:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
update_schema: ${{ steps.check-update-schema.outputs.run_jobs }}
13+
14+
steps:
15+
- name: Check if event should be sent
16+
id: check-update-schema
17+
run: (echo "${{ github.ref }}" | grep -Eq '^refs\/tags\/[0-9]+\.[0-9]+\.[0-9]+$') && echo "::set-output name=run_jobs::true" || echo "::set-output name=run_jobs::false"
18+
919
create_schema:
1020
runs-on: ubuntu-latest
21+
needs: determine_whether_to_run
22+
if: needs.determine_whether_to_run.outputs.update_schema == 'true'
1123
name: Create Schema
1224

1325
steps:
14-
- name: Checkout noss Repo
15-
uses: actions/checkout@v3
16-
with:
17-
path: noss
18-
19-
- name: Checkout oss repo
26+
- name: Checkout oss Repo
2027
uses: actions/checkout@v3
2128
with:
22-
repository: appbaseio/reactivesearch-api
23-
path: oss
24-
token: ${{ secrets.REPO_ACCESS_TOKEN }}
29+
ref: next
2530

2631
- name: Make clean and build
2732
run: make clean && make
28-
working-directory: ./noss
2933

3034
- name: Generate the latest schema
3135
run: ./build/reactivesearch --create-schema
32-
working-directory: ./noss
33-
34-
- name: Remove older schema
35-
run: rm schema -rf
36-
working-directory: ./oss
37-
38-
- name: Copy the built schema to oss
39-
run: cp -r noss/schema oss/
4036

4137
- name: Add and Commit changes
4238
uses: EndBug/add-and-commit@v9
4339
with:
4440
add: schema
4541
default_author: github_actions
4642
message: Update schema for latest release
47-
push: true
48-
cwd: ./oss
43+
push: true

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM golang:1.21.3 AS builder
22

3-
ARG VERSION=8.22.0
3+
ARG VERSION=8.22.2
44
ENV VERSION="${VERSION}"
55

66
# Default value

Dockerfile-byoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM golang:1.21.3 AS builder
22

3-
ARG VERSION=8.22.0
3+
ARG VERSION=8.22.2
44
ENV VERSION="${VERSION}"
55

66
# Default value

Dockerfile-cluster

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM golang:1.21.3 AS builder
22

3-
ARG VERSION=8.22.0
3+
ARG VERSION=8.22.2
44
ENV VERSION="${VERSION}"
55

66
# Default value

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GC=go build
22

33
BUILD_DIR=build
4-
DEFAULT_VERSION=8.22.0
4+
DEFAULT_VERSION=8.22.2
55
VERSION := $(or $(VERSION),$(DEFAULT_VERSION))
66

77
cmd: build

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ReactiveSearch API
22

3-
[![Tests](https://github.com/appbaseio/reactivesearch-api/actions/workflows/tests.yml/badge.svg)](https://github.com/appbaseio/reactivesearch-api/actions/workflows/tests.yml) [![Docker](https://github.com/appbaseio/reactivesearch-api/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/appbaseio/reactivesearch-api/actions/workflows/docker-publish.yml)
3+
[![Tests](https://github.com/appbaseio/reactivesearch-api/actions/workflows/tests.yml/badge.svg)](https://github.com/appbaseio/reactivesearch-api/actions/workflows/tests.yml) [![Docker](https://github.com/appbaseio/reactivesearch-api/actions/workflows/docker-image.yml/badge.svg)](https://github.com/appbaseio/reactivesearch-api/actions/workflows/docker-image.yml)
44

55
ReactiveSearch API is a declarative, open-source API for querying Elasticsearch, OpenSearch, Solr, MongoDB Atlas Search and OpenAI. It also acts as a reverse proxy and API gateway for Elasticsearch and OpenSearch. ReactiveSearch API is best suited for site search, app search and e-commerce search use-cases.
66

ami.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"region": "us-east-1",
1313
"instance_type": "t2.micro",
1414
"ssh_username": "ec2-user",
15-
"source_ami": "ami-00fb60313d8af038f",
15+
"source_ami": "ami-0eaf8bcec9ab4bde5",
1616
"ami_name": "reactivesearch-api-{{user `VERSION` | clean_resource_name}}",
1717
"ssh_timeout": "10m",
1818
"ami_regions": ["us-east-1"],

0 commit comments

Comments
 (0)