Skip to content

Merge pull request #133 from mithunjohny/users/mithunj/pushNotificati… #154

Merge pull request #133 from mithunjohny/users/mithunj/pushNotificati…

Merge pull request #133 from mithunjohny/users/mithunj/pushNotificati… #154

Workflow file for this run

name: Release CI
on:
push:
branches:
- main
tags:
- 'v*'
env:
CACHE_CONTROL_HEADER: public, max-age=86400, s-maxage=259200, must-revalidate
PUBLISH_TO_CDN : false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install az
run: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az
- name: Checking out for ${{ github.ref }}
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.X
- name: Update package version
run: npx version-from-git --no-git-tag-version
if: ${{ startsWith(github.ref, 'refs/heads/') }}
- name: Read package.json
id: read-package-json
run: |
echo "::set-output name=name::$(cat package.json | jq -r '.name')"
echo "::set-output name=version::$(cat package.json | jq -r '.version')"
- name: Install packages
run: npm install
- name: Build CDN & NPM packages
run: |
npm run build:dev
npm run build:prod
- name: Prepare CDN packages
run: |
mkdir ${{ steps.read-package-json.outputs.version }}
cp dist/SDK.js ${{ steps.read-package-json.outputs.version }}
cp dist/SDK.min.js ${{ steps.read-package-json.outputs.version }}
- name: Publish CDN package to versioned blob (dev)
if: ${{ env.PUBLISH_TO_CDN == 'true' }}
run: |
az storage blob upload-batch --connection-string "${{ secrets.BLOBCONNECTIONSTRINGDEV }}" --source "${{ steps.read-package-json.outputs.version }}" --destination "prerelease/${{ steps.read-package-json.outputs.version }}" --content-cache-control "${{ env.CACHE_CONTROL_HEADER }}"
- name: Publish CDN package to latest blob (dev)
if: ${{ env.PUBLISH_TO_CDN == 'true' }}
run: |
az storage blob upload-batch --connection-string "${{ secrets.BLOBCONNECTIONSTRINGDEV }}" --source "${{ steps.read-package-json.outputs.version }}" --destination "prerelease/latest" --content-cache-control "${{ env.CACHE_CONTROL_HEADER }}"
- name: Publish CDN package to versioned blob (prod)
if: ${{ env.PUBLISH_TO_CDN == 'true' }}
run: |
az storage blob upload-batch --connection-string "${{ secrets.BLOBCONNECTIONSTRINGPROD }}" --source "${{ steps.read-package-json.outputs.version }}" --destination "release/${{ steps.read-package-json.outputs.version }}" --content-cache-control "${{ env.CACHE_CONTROL_HEADER }}"
- name: Publish CDN package to latest blob (prod)
if: ${{ env.PUBLISH_TO_CDN == 'true' }}
run: |
az storage blob upload-batch --connection-string "${{ secrets.BLOBCONNECTIONSTRINGPROD }}" --source "${{ steps.read-package-json.outputs.version }}" --destination "release/latest" --content-cache-control "${{ env.CACHE_CONTROL_HEADER }}"
- name: Npm packaging
run: npm pack
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: npm-tarball
path: '*.tgz'
publish:
needs: build
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: actions/[email protected]
with:
name: npm-tarball
- name: Read package.json
id: read-package-json
run: |
echo "::set-output name=name::$(tar xOf *.tgz package/package.json | jq -r '.name')"
echo "::set-output name=version::$(tar xOf *.tgz package/package.json | jq -r '.version')"
echo "::set-output name=tarball::$(ls *.tgz)"
echo "::set-output name=date::$(date +%Y-%m-%d)"
- name: Run npm publish ${{ steps.read-package-json.outputs.name }}@${{ steps.read-package-json.outputs.version }}
run: |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm publish *.tgz --tag master --access public
npm dist-tag add ${{ steps.read-package-json.outputs.name }}@${{ steps.read-package-json.outputs.version }} latest