-
Notifications
You must be signed in to change notification settings - Fork 4
143 lines (141 loc) · 4.92 KB
/
build.yaml
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
name: Build modules
on:
push:
tags:
- v.*
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
outputs:
release: ${{ steps.check.outputs.release }}
steps:
- uses: actions/checkout@v3
- name: Create release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: gh release create ${{ github.ref_name }} --latest --verify-tag
env:
GH_TOKEN: ${{ github.token }}
- name: Get release name
id: check
run : echo release=$(gh release view --json tagName --jq .tagName) >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
build:
runs-on: ubuntu-latest
needs: release
strategy:
matrix:
module:
- naive-lemmatizer
- naive-lemmatizer-less-prefixes
include:
- elastic: 6.2.3
java: '8'
- elastic: 7.17.0
java: '11'
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn -Delasticsearch.version=${{ matrix.elastic }} -Dsefaria.version=${{ needs.release.outputs.release }} package
working-directory: Sefaria-ElasticSearch-${{ matrix.module }}
- name: Populate Properties File
run: |
cat << EOF > out/artifacts/elasticsearch/plugin-descriptor.properties
name=analysis-sefaria-${{ matrix.module }}
description=Sefaria analyzer
classname=org.sefaria.sefariaplugin.plugin.SefariaPlugin
elasticsearch.version=${{ matrix.elastic }}
java.version=${{ matrix.java }}
version=${{ needs.release.outputs.release }}
EOF
working-directory: Sefaria-ElasticSearch-${{ matrix.module }}
- name: Zip Plugin
uses: thedoctor0/[email protected]
with:
type: "zip"
directory: Sefaria-ElasticSearch-${{ matrix.module }}/out/artifacts
filename: ${{ matrix.module }}-${{ needs.release.outputs.release }}-${{ matrix.elastic }}.zip
- name: Upload artifact
run: |
cd Sefaria-ElasticSearch-${{ matrix.module }}/out/artifacts
gh release upload ${{ needs.release.outputs.release }} '${{ matrix.module }}-${{ needs.release.outputs.release }}-${{ matrix.elastic }}.zip' --clobber
env:
GH_TOKEN: ${{ github.token }}
- name: cleanup cache
run: rm -rf *
working-directory: Sefaria-ElasticSearch-${{ matrix.module }}/out/artifacts
container:
runs-on: ubuntu-latest
needs:
- build
- release
strategy:
matrix:
elastic: [6.2.3, 7.17.0]
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
token_format: 'access_token'
workload_identity_provider: 'projects/${{ secrets.PROD_GKE_PROJECT_ID}}/locations/global/workloadIdentityPools/github/providers/github'
service_account: '${{ secrets.PROD_GKE_SA }}'
- name: Login to GCR
uses: docker/login-action@v1
with:
registry: gcr.io
username: oauth2accesstoken
password: '${{ steps.auth.outputs.access_token }}'
- name: Login to GAR
uses: docker/login-action@v1
with:
registry: us-east1-docker.pkg.dev
username: oauth2accesstoken
password: '${{ steps.auth.outputs.access_token }}'
- name: download plugins
run: |
gh release download --pattern '*-${{ matrix.elastic }}.zip'
env:
GH_TOKEN: ${{ github.token }}
- name: debug
run: |
ls -al
pwd
ls build
- name: Generate image metadata
id: meta
uses: docker/metadata-action@v3
with:
images: |
gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-elasticsearch-${{ matrix.elastic }}
us-east1-docker.pkg.dev/${{ secrets.DEV_PROJECT }}/containers/sefaria-elasticsearch-${{ matrix.elastic }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=sha
type=semver,pattern={{raw}},value=${{ needs.release.outputs.release }}
flavor: |
latest=true
- name: build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
build-args: |
PLUGIN_VERSION=${{ needs.release.outputs.release }}
ELASTIC_VERSION=${{ matrix.elastic }}
file: ./build/Sefaria/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}