Pre-release and Publish to NPM #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pre-release and Publish to NPM | |
on: workflow_dispatch | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Setup Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install deps and build | |
run: | | |
yarn | |
yarn build-all | |
publish-gpr: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: "https://registry.npmjs.org" | |
scope: "@layer5" | |
- name: Install deps and build | |
run: yarn | |
- name: Identify changed packages | |
run: | | |
CHANGED_PACKAGES=$(yarn lerna changed --json) | |
echo "Raw JSON output:" | |
echo "$CHANGED_PACKAGES" | |
CHANGED_PACKAGES_NAMES=$(echo "$CHANGED_PACKAGES" | jq -r '.[].name' || echo "Error parsing JSON") | |
echo "Parsed package names:" | |
echo "$CHANGED_PACKAGES_NAMES" | |
- name: Version packages | |
run: ./scripts/version-prerelease-packages.sh $CHANGED_PACKAGES_NAMES | |
- name: Commit changes | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
git add . | |
git commit -m "chore: publish" | |
git push origin HEAD | |
else | |
echo "No changes to commit." | |
fi | |
- name: Create Git tags | |
run: ./scripts/create-multiple-git-tag.sh | |
- name: Publish packages | |
run: yarn lerna publish from-package --yes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |