Skip to content

Publish development packages to NPM #12

Publish development packages to NPM

Publish development packages to NPM #12

Workflow file for this run

name: Publish development packages to NPM
on:
workflow_dispatch:
pull_request:
types:
- closed
branches:
- dev
workflow_run:
workflows: [Update API client (dev)]
types:
- completed
jobs:
publish:
if:
github.event.pull_request.merged == true ||
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLISH_PAT: ${{ secrets.PUBLISH_PAT }}
GH_TOKEN: ${{ secrets.PUBLISH_PAT }}
steps:
- name: Checkout ⬇️
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PUBLISH_PAT }}
ref: ${{ github.event.workflow_run.head_branch }}
- name: Setup Node 🎛️
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
registry-url: "https://registry.npmjs.org"
- name: Git Identity 🪪
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Yarn Install 📦️
run: yarn install --immutable
- name: Setup NX 1/2 🎛️
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: dev
# This step is needed for nx affected to work when CI is running on a PR
# See also https://nx.dev/ci/recipes/set-up/monorepo-ci-github-actions#configuring-ci-using-github-actions-and-nx
- name: Setup NX 2/2 🎛
if:
(github.ref != 'refs/heads/dev' &&
github.event.workflow_run.head_branch != 'dev')
run: git branch --track dev origin/dev
- name: Build 🔨
run: yarn nx affected -t build --parallel=3
# TODO: Uses the previous version. Needs a fix!
- name: Create version file 🔢
run: |
yarn nx run @mittwald/api-client:build:write-version-file
git add .
- name: Version and publish 🚀
if:
github.event.workflow_run.head_branch == 'dev' || github.ref ==
'refs/heads/dev'
run: |
yarn lerna publish 0.0.0-development-$(git rev-parse --short=7 HEAD)-$(date +%Y%m%d) \
--message "chore(release): bump version to %v" \
--yes --no-private \
--tag-version-prefix "" \
--dist-tag development