Skip to content

Merge branch 'main' into release #24

Merge branch 'main' into release

Merge branch 'main' into release #24

name: Release publish NPM
on:
push:
branches:
- release
jobs:
release-publish-npm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm test
- name: Run integration tests
run: npm run if-check -- -d manifests/outputs
- name: Initialize git user email
run: git config --global user.email "${{ env.RELEASE_USER_EMAIL }}"
- name: Initialize git user name
run: git config --global user.name "Release publish workflow"
- name: Initialize npm config
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Fetch latest release info
run: |
RELEASE_JSON=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases")
if [ $? -ne 0 ]; then
echo "Failed to fetch releases"
exit 1
fi
LATEST_RELEASE_NAME=$(echo "$RELEASE_JSON" | jq -r '.[0].name')
IS_PRE_RELEASE=$(echo "$RELEASE_JSON" | jq -r '.[0].prerelease')
echo "LATEST_RELEASE_NAME=$LATEST_RELEASE_NAME" >> $GITHUB_ENV
echo "IS_PRE_RELEASE=$IS_PRE_RELEASE" >> $GITHUB_ENV
- name: Fetch and checkout to release branch
run: |
git fetch --all
git checkout ${{ vars.RELEASE_BRANCH_NAME }}
- name: Publish to npm (pre-release)
if: env.IS_PRE_RELEASE == 'true'
run: npm publish --tag beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm
if: env.IS_PRE_RELEASE == 'false'
run: npm publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}