feat(ci): publish npm package #4
Workflow file for this run
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: package-release | |
on: | |
push: | |
branches: | |
- hgw-build-release | |
#paths: | |
# - package.json | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build-and-publish: | |
runs-on: [ubuntu-latest] | |
env: | |
ACTIONS_RUNNER_DEBUG: true | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
registry-url: https://npm.pkg.github.com/ | |
# @sapcc | |
# this is the scope of the package to publish to the registry-url that is defined above | |
scope: "@${{ github.repository_owner }}" | |
- name: Install dependencies | |
run: npm install | |
- name: Test | |
run: npm run test | |
- name: Build | |
run: | | |
npm run build | |
ls -la | |
- name: Publish to github packages | |
run: | | |
set +e | |
echo "publish to https://github.com/${{ github.repository_owner }}/packages" | |
cat .npmrc | |
npm publish --access=public #--dry-run | |
if [ $? != 0 ] ; then | |
echo "::warning title=PUBLISH::Could not publish to github. Maybe you forgot to increment the version?" | |
exit 0 | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
REPOSITORY_OWNER: ${{ github.repository_owner }} |