Release NPM packages #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: Release NPM packages | |
env: | |
NODE_OPTIONS: --max-old-space-size=6144 | |
NX_MAX_PARALLEL: 2 | |
on: | |
workflow_dispatch: | |
inputs: | |
release_as: | |
type: 'choice' | |
description: 'The release type. It can be one of: major, minor, patch, premajor, preminor, prepatch, or prerelease. Defaults to "patch"' | |
required: true | |
default: 'patch' | |
options: | |
- major | |
- minor | |
- patch | |
- premajor | |
- preminor | |
- prepatch | |
- prerelease | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
# Only release from the main branch | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Necessary for nx affected commands | |
fetch-depth: 0 | |
- name: Setup | |
uses: ./.github/actions/setup | |
with: | |
git_bot_token: ${{ secrets.GIT_BOT_TOKEN }} | |
- name: Release @ngworker/lumberjack | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
# Generates the changelog commit and tags and pushes them to Github. | |
# Use two post actions to Create a release in Github and for Publishing the package to NPM | |
shell: bash | |
run: pnpm exec nx version ngworker-lumberjack --releaseAs=${{ github.event.inputs.release_as }} | |
# Needed if we want to automize multiple releases with the affected commands. | |
- name: Tag last-release | |
shell: bash | |
run: git tag -f last-release | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GH_TOKEN }} | |
branch: ${{ github.ref }} | |
force: true | |
tags: true | |
deploy-docs: | |
name: '[Merge] Deploy docs to GitHub Pages' | |
needs: release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
actions: read | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Check out the source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup | |
uses: ./.github/actions/setup | |
# Uses the cache generated in the distributed step | |
- name: Build docs | |
run: pnpm exec nx build docs-lumberjack-docs-app | |
- name: Set up GitHub Pages | |
uses: actions/configure-pages@v4 | |
- name: Upload docs to GitHub Pages | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: dist/packages/docs/lumberjack-docs-app/ | |
- name: Deploy docs to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |