Skip to content

Publish packages

Publish packages #235

Workflow file for this run

name: Publish packages
on:
workflow_run:
workflows: ['Version Packages']
types:
- completed
workflow_dispatch:
jobs:
publish:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.11.0'
registry-url: https://npm.pkg.github.com/
scope: '@carlsberg'
- name: Configure Git
run: |
git config --global user.name "carlsberg-release-app[bot]"
git config --global user.email "carlsberg-release-app[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
- name: Set npm registry and authentication
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: |
if [ -e yarn.lock ]; then
yarn install
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
- name: Stash .npmrc changes
run: git stash push --keep-index --message "Stashing .npmrc changes"
continue-on-error: true
- name: Build packages
run: yarn build
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish packages
run: npx lerna publish from-package --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Unstash .npmrc changes
if: failure()
run: git stash pop