This repository has been archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.41 KB
/
release.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
name: Build release
on:
push:
tags:
- "v*"
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm test
build:
name: Build with google cloud
runs-on: ubuntu-latest
env:
PROJECT_ID: ${{ secrets.GCP_BUILD_PROJECT_ID }}
# Extract version tags from tag
steps:
- name: Setup variables
id: variables
run: |
TAG_NAME=${GITHUB_REF/refs\/tags\//}
FULL_V_TAG=$(echo $TAG_NAME | sed -r 's/^v(.+)/\1/')
MINOR_V_TAG=$(echo $FULL_V_TAG | sed -r -e 's/.*-(\w+)/\1/' -e 's/(^[0-9]+\.[0-9]+).*/\1/')
MAJOR_V_TAG=$(echo $MINOR_V_TAG | sed -r -e 's/(^[a-z]+).*/\1/' -e 's/(^[0-9]+).*/\1/')
echo ::set-output name=full_version_tag::$FULL_V_TAG
echo ::set-output name=minor_version_tag::$MINOR_V_TAG
echo ::set-output name=major_version_tag::$MAJOR_V_TAG
- name: Checkout
uses: actions/checkout@v3
- run: |
sudo apt-get install python2.7
export CLOUDSDK_PYTHON="/usr/bin/python2"
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v0
with:
version: "286.0.0"
project_id: ${{ secrets.GCP_BUILD_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_EMAIL }}
service_account_key: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_KEY }}
# Build and push image to Google Container Registry
- name: Build
run: |-
gcloud builds submit \
--quiet \
--tag "eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA"
- name: Tag image
run: |-
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.full_version_tag }}"
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.minor_version_tag }}"
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.major_version_tag }}"