-
Notifications
You must be signed in to change notification settings - Fork 51
174 lines (149 loc) · 5.95 KB
/
public_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
# This workflow is meant to:
# 1. Create a new git tag
# 2. Create a new release artifact in github repo
# 3. Create a new helm chart package and upload it as a release artifact
#
# This is meant to ONLY happen when VERSION file is updated and pushed to main branch
# and meant to be used as a mechanism to communicate sets of changes to the public.
# Since we deploy in a CD way, the way we release and communicate differs internally from externally
name: Tag and public artifact release
env:
API_VERSION: 1
on:
push:
branches:
- main
paths:
- 'VERSION'
jobs:
release:
name: Tag and release
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Calculate short sha
id: env-vars
run: |-
HASH=`git rev-parse --short HEAD`
echo "short_sha=$HASH" >> $GITHUB_OUTPUT
- name: Get version
id: version_step
run: |-
VERSION=`cat VERSION`
HASH=`git rev-parse --short HEAD`
echo "version_number=$VERSION" >> $GITHUB_OUTPUT
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Update image version
uses: mikefarah/yq@master
with:
cmd: yq -i '.imageVersion = "${{ steps.version_step.outputs.hash }}"' 'charts/nucliadb/values.yaml'
- name: Set chart version
uses: mikefarah/yq@master
with:
cmd: yq -i '.version = "${{ steps.version_step.outputs.version_number }}"' 'charts/nucliadb/Chart.yaml'
- name: Set chart app version
uses: mikefarah/yq@master
with:
cmd: yq -i '.appVersion = "${{ steps.version_step.outputs.version_number }}"' 'charts/nucliadb/Chart.yaml'
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v3.15.3
- name: Build helm package
run: |-
helm lint charts/nucliadb
helm package charts/nucliadb
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.version_step.outputs.version_number }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version_step.outputs.version_number }}
release_name: Release ${{ steps.version_step.outputs.version_number }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./nucliadb-${{ steps.version_step.outputs.version_number }}.tgz
asset_name: nucliadb-chart.tgz
asset_content_type: application/tar+gzip
tag-stable:
name: Tag current latest as stable
runs-on: ubuntu-24.04
if: github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get version
id: version_step
run: |-
VERSION=`cat VERSION`
echo "version_number=$VERSION" >> $GITHUB_OUTPUT
- name: Tag it
run: |-
docker pull nuclia/nucliadb:latest
docker tag nuclia/nucliadb:latest nuclia/nucliadb:stable
docker tag nuclia/nucliadb:latest nuclia/nucliadb:${{ steps.version_step.outputs.version_number }}
docker push nuclia/nucliadb:stable
docker push nuclia/nucliadb:${{ steps.version_step.outputs.version_number }}
docs:
name: 'Upload API specs'
runs-on: ubuntu-24.04
if: github.event_name == 'push'
steps:
- name: Generate a token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.GHAPP_ID_NUCLIABOT }}
private-key: ${{ secrets.PK_GHAPP_NUCLIABOT }}
owner: nuclia
- name: Checkout
uses: actions/checkout@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.12.5"
cache: "true"
- name: Install nucliadb
run: pdm sync -d --clean --no-editable
- name: Setup gcloud CLI
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: Upload docs
run: |
mkdir -p /tmp/openapi
source .venv/bin/activate
nucliadb-extract-openapi-reader /tmp/openapi/nucliadb-reader.json $API_VERSION $GITHUB_SHA
nucliadb-extract-openapi-writer /tmp/openapi/nucliadb-writer.json $API_VERSION $GITHUB_SHA
nucliadb-extract-openapi-search /tmp/openapi/nucliadb-search.json $API_VERSION $GITHUB_SHA
gsutil copy /tmp/openapi/nucliadb-reader.json gs://stashify-docs/api/nucliadb/v$API_VERSION/nucliadb-reader/spec.json
gsutil copy /tmp/openapi/nucliadb-writer.json gs://stashify-docs/api/nucliadb/v$API_VERSION/nucliadb-writer/spec.json
gsutil copy /tmp/openapi/nucliadb-search.json gs://stashify-docs/api/nucliadb/v$API_VERSION/nucliadb-search/spec.json
- name: Trigger doc update
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.app-token.outputs.token }}
repository: nuclia/docs
event-type: merge