Skip to content

Commit

Permalink
Inf 371 community release workflow (#5595)
Browse files Browse the repository at this point in the history
* feat(ci): Community releases

* feat(ci): REGISTRY_OWNER change

* feat(ci): WF name has been changed

* feat(ci): Option to choose a service

* fix(ci): Fix condition

* fix(ci): Embed service ahs been added

* feat(ci): No environment

* feat(ci): Getting a release version from Lerna

* feat(ci): Environment has been added

* feat(ci): Another way to get Lerna release version

* feat(ci): Echo LERNA_RELEASE_VERSION

* feat(ci): Echo LERNA_RELEASE_VERSION

* feat(ci): Output fix

* feat(ci): GH_PACKAGES secret

* feat(ci): Matrix name instead of service name

* feat(ci): Tag option and timeout update

* feat(ci): Free space action has been added

* feat(ci): EE for the community releases

* fix(ci): Service path fix

* fix(ci): Service path fix

* fix(ci): Rename variable

* fix(ci): Submodules fix

* fix(ci): Submodules fix

* fix(ci): Submodules fix

* fix(ci): Submodules condition

* fix(ci): Branch has been deleted

* fix(ci): Condition update

* fix(ci): Condition update

* fix(ci): Condition update

* fix(ci): Pawel's recommendations

* fix(ci): Full matrix + latest tag for community releases

* Update .github/workflows/community-releases.yml

Co-authored-by: Sokratis Vidros <[email protected]>

* Update .github/workflows/community-releases.yml

Co-authored-by: Sokratis Vidros <[email protected]>

* Update .github/workflows/community-releases.yml

Co-authored-by: Sokratis Vidros <[email protected]>

* Update .github/workflows/community-releases.yml

Co-authored-by: Sokratis Vidros <[email protected]>

* Update .github/workflows/community-releases.yml

Co-authored-by: Sokratis Vidros <[email protected]>

* Update .github/workflows/community-releases.yml

Co-authored-by: Sokratis Vidros <[email protected]>

* fix(ci): Variable renaming

* fix(ci): Syntax fix

* fix(ci): Job renaming

* fix(ci): Environment + ws-ee and webhook-ee have been added in the matrix

* fix(ci): Link submodules after pnpm install

* fix(ci): PNPM version update

* feat(ci): A new approach without tagging of a git repository during WF running

* feat(ci): Output has been deleted

* fix(ci): Fix of check

---------

Co-authored-by: Sokratis Vidros <[email protected]>
  • Loading branch information
AliaksandrRyzhou and SokratisVidros committed Jun 13, 2024
1 parent 6cce8aa commit 99a5299
Showing 1 changed file with 61 additions and 34 deletions.
95 changes: 61 additions & 34 deletions .github/workflows/community-releases.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: Prepare Self-hosted Release

on:
workflow_dispatch:
inputs:
version:
description: 'The version to tag docker images'
required: true
type: string
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
contents: write
Expand All @@ -17,27 +14,55 @@ permissions:
jobs:
prepare:
runs-on: ubuntu-latest
timeout-minutes: 80
timeout-minutes: 60
outputs:
latest-version: ${{ steps.get_version.outputs.latest-version }}
steps:
- uses: actions/checkout@v4
- name: Get Current Lerna Release version and comparing with the Git tag
id: get_version
shell: bash
run: |
LATEST_VERSION="v$(jq -r '.version' lerna.json)"
CURRENT_GIT_TAG="${{ github.ref_name }}"
if [ "$LATEST_VERSION" == "$CURRENT_GIT_TAG" ]
then
echo "latest-version=$(jq -r '.version' lerna.json)" >> $GITHUB_OUTPUT
else
echo "::error::The version in the file lerna.json does not match the git tag. The version in lerna.json is $LATEST_VERSION. The git version is $CURRENT_GIT_TAG"
exit 1
fi
docker_build:
build_docker:
runs-on: ubuntu-latest
needs: prepare
timeout-minutes: 80
timeout-minutes: 90
environment: Production
strategy:
fail-fast: false
matrix:
name: ['novu/api','novu/worker','novu/inbound-mail','novu/web','novu/webhook','novu/widget','novu/ws']
name: ['novu/api','novu/worker','novu/inbound-mail','novu/web','novu/webhook','novu/widget','novu/ws','novu/embed','novu/inbound-mail-ee','novu/worker-ee','novu/api-ee','novu/web-ee','novu/widget-ee','novu/embed-ee','novu/ws-ee','novu/webhook-ee']
steps:
- uses: actions/checkout@v4
- name: Git Checkout with Submodules
uses: actions/checkout@v4
if: contains(matrix.name, '-ee')
with:
submodules: true
token: ${{ secrets.SUBMODULES_TOKEN }}

- name: Git Checkout without Submodules
if: "!contains(matrix.name, '-ee')"
uses: actions/checkout@v4

- name: Variables
shell: bash
run: |
echo "The release version is ${{ needs.prepare.outputs.latest-version }}"
service=${{ matrix.name }}
echo "SERVICE_NAME=$(basename "${service//-/-}")" >> $GITHUB_ENV
SERVICE_NAME=$(basename "${service//-/-}")
SERVICE_COMMON_NAME=$(echo "$SERVICE_NAME" | sed 's/-ee$//')
echo "SERVICE_NAME=$SERVICE_NAME" >> $GITHUB_ENV
echo "SERVICE_COMMON_NAME=$SERVICE_COMMON_NAME" >> $GITHUB_ENV
echo "REGISTRY_OWNER=novuhq" >> $GITHUB_ENV
- name: Install pnpm
Expand All @@ -48,20 +73,32 @@ jobs:
with:
node-version: 20.8.1
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Link submodules
if: contains(matrix.name, '-ee')
run: pnpm symlink:submodules

- uses: ./.github/actions/free-space
- uses: ./.github/actions/setup-qemu

- name: Login To Registry
shell: bash
env:
GH_ACTOR: ${{ github.actor }}
GH_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GH_PASSWORD: ${{ secrets.GH_PACKAGES }}
run: |
echo $GH_PASSWORD | docker login ghcr.io -u $GH_ACTOR --password-stdin
- name: Build Community Docker Image with Buildx, tag, and test
- name: Set Bull MQ Env variable for EE
if: contains(matrix.name, '-ee')
shell: bash
run: |
echo "BULL_MQ_PRO_NPM_TOKEN=${{ secrets.BULL_MQ_PRO_NPM_TOKEN }}" >> $GITHUB_ENV
- name: Build ${{ env.SERVICE_NAME }} Community Docker Image
shell: bash
env:
DOCKER_BUILD_ARGUMENTS: >
Expand All @@ -70,28 +107,18 @@ jobs:
--platform=linux/amd64,linux/arm64 --provenance=false
--output=type=image,name=ghcr.io/${{ env.REGISTRY_OWNER }}/${{ env.SERVICE_NAME }},push-by-digest=true,name-canonical=true
run: |
cd apps/$SERVICE_NAME && pnpm run docker:build
if [ "${{ env.SERVICE_NAME }}" = "embed" ] || [ "${{ env.SERVICE_NAME }}" = "embed-ee" ]; then
cd libs/$SERVICE_COMMON_NAME
else
cd apps/$SERVICE_COMMON_NAME
fi
pnpm run docker:build
docker images
- name: Tag and Push docker image
shell: bash
run: |
docker tag novu-$SERVICE_NAME ghcr.io/$REGISTRY_OWNER/$SERVICE_NAME:${{ inputs.version }}
docker push ghcr.io/$REGISTRY_OWNER/$SERVICE_NAME:${{ inputs.version }}
tag_create:
runs-on: ubuntu-latest
needs: docker_build
timeout-minutes: 80
steps:
- uses: actions/checkout@v4
- name: Create tag ${{ inputs.version }}
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ inputs.version }}',
sha: context.sha
})
docker tag novu-$SERVICE_COMMON_NAME ghcr.io/$REGISTRY_OWNER/${{ matrix.name }}:${{ needs.prepare.outputs.latest-version }}
docker tag novu-$SERVICE_COMMON_NAME ghcr.io/$REGISTRY_OWNER/${{ matrix.name }}:latest
docker push ghcr.io/$REGISTRY_OWNER/${{ matrix.name }}:${{ needs.prepare.outputs.latest-version }}
docker push ghcr.io/$REGISTRY_OWNER/${{ matrix.name }}:latest

0 comments on commit 99a5299

Please sign in to comment.