Skip to content

build: fix release workflow #5

build: fix release workflow

build: fix release workflow #5

Workflow file for this run

name: Build release
on:
push:
tags:
- "v*"
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: find . -name 'package-lock.json' -execdir npm ci \;
- name: Run server
run: npm start &
- name: Wait for server to start
run: npx wait-on tcp:8585
- name: Run tests
run: npm run 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 "full_version_tag=$FULL_V_TAG" >> $GITHUB_OUTPUT
echo "minor_version_tag=$MINOR_V_TAG" >> $GITHUB_OUTPUT
echo "major_version_tag=$MAJOR_V_TAG" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
- id: auth
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_KEY }}
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v2
# Build and push image to Google Container Registry
- name: Build
run: |-
gcloud builds submit \
--quiet \
--tag "eu.gcr.io/$PROJECT_ID/functions:$GITHUB_SHA"
- name: Tag image
run: |-
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/functions:${{ steps.variables.outputs.full_version_tag }}"
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/functions:${{ steps.variables.outputs.minor_version_tag }}"
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/functions:${{ steps.variables.outputs.major_version_tag }}"