From 4a3231e5d92d4ac9702f0ec8592331cacb46844b Mon Sep 17 00:00:00 2001 From: Antoine Bouhours Date: Wed, 3 Jul 2024 12:42:24 +0200 Subject: [PATCH] Add GitHub action to automate release (#83) Signed-off-by: BOUHOURS Antoine --- .github/workflows/publish.yml | 18 ++++++++++++++++++ README.md | 16 ++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..1c519ef8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,18 @@ +name: Publish +on: + release: + types: [ published ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + - run: npm install + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 3537f7f2..38f4465e 100644 --- a/README.md +++ b/README.md @@ -28,16 +28,12 @@ you need to follow the steps below: - Update to the new version in [package.json](https://github.com/powsybl/powsybl-diagram-viewer/blob/main/package.json) (example `0.6.0`) - Update the package-lock.json: `npm install` - Commit the package.json and package-lock.json files, push to a branch, make a PR, have it reviewed and merged to main. -- Pull and checkout main on your last commit. -- [Tag your last commit](https://semver.org/) : `git tag ` (example: `git tag v0.6.0`) -- Push tag : `git push origin ` ---- -- (Optional) Checkout the tag in a fresh repo copy : `cd $(mktemp -d) && git clone https://github.com/powsybl/powsybl-diagram-viewer.git` then `cd powsybl-diagram-viewer && git checkout ` -- (Optional) [Test your package](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages#testing-your-package): `npm install` ---- -- Build the package - npm will publish the README.md, the package.json and the dist directory you just generate : `npm run build` -- [Login on the command line to the npm registry](https://docs.npmjs.com/logging-in-to-an-npm-enterprise-registry-from-the-command-line): `npm login` -- [Publish the package](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages#publishing-scoped-public-packages): `npm publish` +- [Make a release](https://github.com/powsybl/powsybl-diagram-viewer/releases/new) on GitHub by creating a new tag on the last commit. On the release creation page: + - In "Choose a tag": type the tag you want to create (ex.: v0.6.0) and select "create new tag" + - In "Target": click on "recent commit" tab and select your release commit + - Click on "Generate release note" + - Click on "Publish release" +- It will trigger a job that will publish the release on NPM Notes : * Check [license-checker-config.json](license-checker-config.json) for license white list and exclusion.