Skip to content

Merge pull request #291 from Finastra/develop #104

Merge pull request #291 from Finastra/develop

Merge pull request #291 from Finastra/develop #104

Workflow file for this run

name: Release
on:
push:
branches:
- master
jobs:
publish:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
package: [oidc, proxy, logger, ffdc-apis/corporate-accounts]
steps:
# Setup
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node.js modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install Dependencies
run: npm ci --loglevel=error
# Build
- name: Artifact name formatting
run: |
artifactName="${packagePath////-}"
libName="${packagePath##*/}"
echo "Artifact name : ${artifactName}"
echo "Library name : ${libName}"
echo "artifactName=$artifactName" >> $GITHUB_ENV
echo "libName=$libName" >> $GITHUB_ENV
env:
packagePath: ${{ matrix.package }}
- name: Build Package
run: npm run build -- ${{ env.libName }}
- name: Upload Artifact
uses: actions/[email protected]
with:
name: '${{ env.artifactName }}'
path: './dist/libs/${{ matrix.package }}'
# Publish
- name: Publish package
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.FFDC_BOT_NPM_AUTH_TOKEN }}
package: ./dist/libs/${{ matrix.package }}/package.json
access: public
# Tag
- name: Get Release Version
run: |
RELEASE_VERSION=$(node -p '"${{ matrix.package }}-" + require("./dist/libs/${{ matrix.package }}/package.json").version')
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
- name: Check Tag
id: tag_check
run: |
GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/v${RELEASE_VERSION}"
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
-H "Authorization: token ${GITHUB_TOKEN}")
if [ "$http_status_code" -ne "404" ] ; then
echo "::set-output name=exists_tag::true"
else
echo "::set-output name=exists_tag::false"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Tag
if: steps.tag_check.outputs.exists_tag == 'false'
uses: pkgdeps/git-tag-action@v2
with:
version: ${{ env.RELEASE_VERSION }}
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
git_commit_sha: ${{ github.sha }}