Release NPM packages #13
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: npx 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 |