Publish CI #16
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: Publish CI | |
on: | |
workflow_run: | |
workflows: [ "Test CI" ] | |
branches: [ main ] # It is stipulated that Core CI must be performed on the main branch. | |
types: [ completed ] | |
jobs: | |
publish_core: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./packages/core | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Check version | |
id: check | |
run: | | |
PACKAGE_VERSION=$(node -p -e "require('./package.json').version") | |
echo "Version: $PACKAGE_VERSION" | |
HTTP_STATUS=$(curl --silent --head --write-out "%{http_code}" --output /dev/null https://registry.npmjs.org/@data-story/core/$PACKAGE_VERSION) | |
if [ $HTTP_STATUS -eq 200 ]; then | |
echo "Version $PACKAGE_VERSION already exists. Exiting the action script." | |
echo "VERSION_EXISTS=true" >> $GITHUB_ENV | |
else | |
echo "Version does not exist." | |
echo "VERSION_EXISTS=false" >> $GITHUB_ENV | |
fi | |
- name: Check Test CI status | |
if: > | |
github.event.workflow_run.conclusion == 'failure' || | |
github.event.workflow_run.conclusion == 'cancelled' | |
run: | | |
echo "The 'Test CI' workflow is ${{ github.event.workflow_run.conclusion }}." | |
exit 1 # Exit with a failure | |
- name: Install dependencies | |
if: ${{ env.VERSION_EXISTS == 'false' }} | |
run: yarn | |
- name: Build | |
if: ${{ env.VERSION_EXISTS == 'false' }} | |
run: yarn build | |
- name: Publish | |
if: ${{ env.VERSION_EXISTS == 'false' }} | |
run: | | |
yarn config set -H npmScopes.data-story.npmPublishRegistry "https://registry.npmjs.org/" | |
yarn config set -H npmScopes.data-story.npmAuthToken "${{ secrets.NPM_DATA_STORY }}" | |
yarn npm publish --access public | |
publish_ui: | |
needs: publish_core | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Check version | |
id: check | |
run: | | |
PACKAGE_VERSION=$(node -p -e "require('./packages/ui/package.json').version") | |
echo "Version: $PACKAGE_VERSION" | |
HTTP_STATUS=$(curl --silent --head --write-out "%{http_code}" --output /dev/null https://registry.npmjs.org/@data-story/ui/$PACKAGE_VERSION) | |
if [ $HTTP_STATUS -eq 200 ]; then | |
echo "Version $PACKAGE_VERSION already exists. Exiting the action script." | |
echo "VERSION_EXISTS=true" >> $GITHUB_ENV | |
else | |
echo "Version does not exist." | |
echo "VERSION_EXISTS=false" >> $GITHUB_ENV | |
fi | |
- name: Check Core Publish status | |
if: > | |
github.event.workflow_run.conclusion == 'failure' || | |
github.event.workflow_run.conclusion == 'cancelled' | |
run: | | |
echo "The 'Core Publish' workflow is ${{ github.event.workflow_run.conclusion }}." | |
exit 1 # Exit with a failure | |
- name: Install dependencies | |
if: ${{ env.VERSION_EXISTS == 'false' }} | |
run: yarn | |
- name: Build | |
if: ${{ env.VERSION_EXISTS == 'false' }} | |
run: yarn build | |
- name: Publish | |
if: ${{ env.VERSION_EXISTS == 'false' }} | |
run: | | |
yarn config set -H npmScopes.data-story.npmPublishRegistry "https://registry.npmjs.org/" | |
yarn config set -H npmScopes.data-story.npmAuthToken "${{ secrets.NPM_DATA_STORY }}" | |
cd packages/ui && yarn npm publish --access public | |
publish_nodejs: | |
needs: publish_core | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./packages/nodejs | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Check version | |
id: check | |
run: | | |
PACKAGE_VERSION=$(node -p -e "require('./package.json').version") | |
echo "Version: $PACKAGE_VERSION" | |
HTTP_STATUS=$(curl --silent --head --write-out "%{http_code}" --output /dev/null https://registry.npmjs.org/@data-story/nodejs/$PACKAGE_VERSION) | |
if [ $HTTP_STATUS -eq 200 ]; then | |
echo "Version $PACKAGE_VERSION already exists. Exiting the action script." | |
echo "VERSION_EXISTS=true" >> $GITHUB_ENV | |
else | |
echo "Version does not exist." | |
echo "VERSION_EXISTS=false" >> $GITHUB_ENV | |
fi | |
- name: Check Core Publish status | |
if: > | |
github.event.workflow_run.conclusion == 'failure' || | |
github.event.workflow_run.conclusion == 'cancelled' | |
run: | | |
echo "The 'Core Publish' workflow is ${{ github.event.workflow_run.conclusion }}." | |
exit 1 # Exit with a failure | |
- name: Check Test CI status | |
if: > | |
github.event.workflow_run.conclusion == 'failure' || | |
github.event.workflow_run.conclusion == 'cancelled' | |
run: | | |
echo "The 'Test CI' workflow is ${{ github.event.workflow_run.conclusion }}." | |
exit 1 # Exit with a failure | |
- name: Install dependencies | |
if: ${{ env.VERSION_EXISTS == 'false' }} | |
run: yarn | |
- name: Build | |
if: ${{ env.VERSION_EXISTS == 'false' }} | |
run: yarn build | |
- name: Publish | |
if: ${{ env.VERSION_EXISTS == 'false' }} | |
run: | | |
yarn config set -H npmScopes.data-story.npmPublishRegistry "https://registry.npmjs.org/" | |
yarn config set -H npmScopes.data-story.npmAuthToken "${{ secrets.NPM_DATA_STORY }}" | |
yarn npm publish --access public |