Skip to content

Commit

Permalink
add publish next
Browse files Browse the repository at this point in the history
  • Loading branch information
amerharb committed Mar 11, 2024
1 parent f045a80 commit 9f53606
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/publish-next.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Publish Next
on:
release:
types: [ prereleased ]

env:
TAG_NAME: ${{ github.event.release.tag_name }}
PACKAGE_NAME: "" # to be filled later
PACKAGE_VERSION: "" # to be filled later after checkout

jobs:
publish:
name: Publish next to npm
runs-on: ubuntu-latest
steps:
- name: fill package name
run: |
if [[ $TAG_NAME =~ ^eastern-arabic\/v.* ]]; then
PACKAGE_NAME="@numerals/eastern-arabic"
else
echo "❌ tag name: $TAG_NAME doesn't point to any publishable package"
exit 1
fi
echo "📦 Package name: $PACKAGE_NAME"
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
- uses: actions/checkout@v4

- name: fill package version
run: |
PACKAGE_VERSION=$(jq -r '.version' packages/$PACKAGE_NAME/package.json)
echo "🔢 Package version: $PACKAGE_VERSION"
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
- name: validate tag name
run: |
if [[ ! $TAG_NAME =~ ^$PACKAGE_NAME\/v([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)-next\.([0-9]|[1-9][0-9]*)$ ]]; then
echo "❌ Invalid tag name: $TAG_NAME not suitable for @next tag"
exit 1
else
echo "✅ Valid tag name: $TAG_NAME"
fi
- name: validate version in package.json
run: |
if [[ ! $PACKAGE_VERSION =~ ^([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)-next\.([0-9]|[1-9][0-9]*)$ ]]; then
echo "❌ Invalid version name: $PACKAGE_VERSION not suitable for @next publish"
exit 1
else
echo "✅ Valid @next version: $PACKAGE_VERSION"
fi
- name: check if version in package.json is matching tag name
run: |
if [[ "$PACKAGE_NAME/v$PACKAGE_VERSION" != $TAG_NAME ]]; then
echo "❌ Version in package.json of $PACKAGE_NAME: $PACKAGE_VERSION is not matching with tag name: $TAG_NAME"
exit 1
else
echo "✅ Version: $PACKAGE_VERSION in package.json of $PACKAGE_NAME is matching with tag name: $TAG_NAME"
fi
- uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: https://registry.npmjs.org
always-auth: true
cache: yarn

- run: yarn workspaces foreach --all install --immutable
- run: yarn lint
- run: yarn build
- run: yarn test

- name: publish @numerals/eastern-arabic @next to npm
if: ${{ env.PACKAGE_NAME == '@numerals/eastern-arabic' }}
run: yarn workspace eastern-arabic npm publish --access public --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.EASTERN_ARABIC_PUBLISH_AUTH_TOKEN }}

0 comments on commit 9f53606

Please sign in to comment.