From 311d9f2779950833892590dfe112721a8715a3df Mon Sep 17 00:00:00 2001 From: Amninder Kaur Date: Fri, 12 Jan 2024 12:36:51 +1100 Subject: [PATCH] chore: adding tag --- .github/workflows/build.yml | 7 +++++ .github/workflows/ghcr_publish.yml | 42 ++++++++++++++++++++++++++++++ .github/workflows/npm_build.yml | 18 +++++++++++++ bin/ghcr-publish.sh | 13 +++++++++ bin/npm-build.sh | 12 +++++++++ bin/ubuntu-setup.sh | 4 +++ 6 files changed, 96 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/ghcr_publish.yml create mode 100644 .github/workflows/npm_build.yml create mode 100644 bin/ghcr-publish.sh create mode 100644 bin/npm-build.sh create mode 100755 bin/ubuntu-setup.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b1f5540 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,7 @@ +name: build + +on: push + +jobs: + npm_build: + uses: ./.github/workflows/npm_build.yml diff --git a/.github/workflows/ghcr_publish.yml b/.github/workflows/ghcr_publish.yml new file mode 100644 index 0000000..c357dc9 --- /dev/null +++ b/.github/workflows/ghcr_publish.yml @@ -0,0 +1,42 @@ +name: ghcr.io Publish + +# when a new release is created or new tag is pushed to master +# tag should be in the format v1.0.0 +# v1.0.0-alpha.1 is also valid +# regex to check the tag format +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]' + - 'v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]+' + - 'v[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z]+)+.[0-9]?' + +jobs: + build: + uses: ./.github/workflows/npm_build.yml + publish: + runs-on: ubuntu-latest + needs: build + if: needs.build.result == 'success' + steps: + - name: Checkout the repo + uses: actions/checkout@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - run: PATH=$PATH:$(pwd) bin/ubuntu-setup.sh + - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - run: | + echo $RELEASE_VERSION + echo ${{ env.RELEASE_VERSION }} + + + - name: Build and publish lock manager image with ver and latest tag + run: sh bin/ghcr-publish.sh lock-manager ${{ env.RELEASE_VERSION }} + + + + diff --git a/.github/workflows/npm_build.yml b/.github/workflows/npm_build.yml new file mode 100644 index 0000000..5a19dfb --- /dev/null +++ b/.github/workflows/npm_build.yml @@ -0,0 +1,18 @@ +# workflow_call to build the rust app +name: npm_build_and_test + +on: workflow_call + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + check-latest: true + - name: npm install, build and test lock-manager + run: sh bin/npm-build.sh lock-manager diff --git a/bin/ghcr-publish.sh b/bin/ghcr-publish.sh new file mode 100644 index 0000000..e65c02f --- /dev/null +++ b/bin/ghcr-publish.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e +package_name=$1 +version=$2 + +docker_file=$package_name/Dockerfile +tag_with_version=pit-$package_name:v$version +tag_ref=ghcr.io/kindredgroup/pit-toolkit/$tag_with_version +echo $tag_ref +docker build -f $docker_file . --tag $tag_ref +#for ghcr.io access token mentioned in the github secrets and accessed in actions +docker push $tag_ref diff --git a/bin/npm-build.sh b/bin/npm-build.sh new file mode 100644 index 0000000..3c5bbe8 --- /dev/null +++ b/bin/npm-build.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +package_name=$1 + +echo $(pwd) +cd $(pwd)/$package_name +npm install +npm run build +npm run test +cd ../ diff --git a/bin/ubuntu-setup.sh b/bin/ubuntu-setup.sh new file mode 100755 index 0000000..1f49a91 --- /dev/null +++ b/bin/ubuntu-setup.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +sudo apt-get update && sudo apt-get install -y libsasl2-dev