From 82948d975524a31e44982dc0784f434176dabd52 Mon Sep 17 00:00:00 2001 From: Tom Chen Date: Tue, 9 Feb 2021 13:16:02 +0100 Subject: [PATCH] feat: change publish strategy: github release & npm publish after v tag pushing; update readme --- .github/workflows/publish.yml | 23 +++++++++++++++++++++-- README.md | 10 +++++++--- package-lock.json | 6 +++--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index aa835c1..553bb0e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,8 +1,27 @@ -name: Publish +name: Release & Publish on: + push: + tags: + - 'v*' + +jobs: release: - types: [created] + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: false jobs: publish: diff --git a/README.md b/README.md index 6564cb9..7a255b4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This is an example TypeScript Package ready to be published on npm. It has been [![npm package](https://img.shields.io/badge/npm%20i-example--typescript--package-brightgreen)](https://www.npmjs.com/package/example-typescript-package) [![version number](https://img.shields.io/npm/v/example-typescript-package?color=green&label=version)](https://github.com/tomchen/example-typescript-package/releases) [![Actions Status](https://github.com/tomchen/example-typescript-package/workflows/Test/badge.svg)](https://github.com/tomchen/example-typescript-package/actions) [![License](https://img.shields.io/github/license/tomchen/example-typescript-package)](https://github.com/tomchen/example-typescript-package/blob/main/LICENSE) -It uses npm, TypeScript compiler, Jest, webpack, ESLint, Prettier. The production files include CommonJS, ES Modules, UMD version and TypeScript declaration files. +It uses npm, TypeScript compiler, Jest, webpack, ESLint, Prettier, husky, commitlint. The production files include CommonJS, ES Modules, UMD version and TypeScript declaration files.

Github Visual Studio Code Windows Mac OS Linux npm Typescript Jest webpack ESLint Prettier yarn @@ -54,6 +54,8 @@ Test your code with Jest framework: npm run test ``` +**Note:** Example TypeScript Package uses [husky](https://typicode.github.io/husky/) and [commitlint](https://commitlint.js.org/) to automatically execute test and [lint commit message](https://www.conventionalcommits.org/) before every commit. + ### Build Build production (distribution) files in your **dist** folder: @@ -146,9 +148,11 @@ If you publish your package to npm only, and don't want to publish to GitHub Pac Now everything is set. The example package has automated tests and upload (publishing) already set up with GitHub Actions: - Every time you `git push` or a pull request is submitted on your `master` or `main` branch, the package is automatically tested against the desired OS and Node.js versions with GitHub Actions. -- Every time a new release (either the initial version or an updated version) is created, the latest version of the package is automatically published to npm and/or GitHub Packages registry with GitHub Actions. +- Every time an [**annotated**](https://git-scm.com/book/en/v2/Git-Basics-Tagging#_annotated_tags) (not [lightweight](https://git-scm.com/book/en/v2/Git-Basics-Tagging#_lightweight_tags)) "v*" tag is pushed onto GitHub, a GitHub release is automatically generated from this version, it also automatically publishes to the npm registry and/or GitHub Packages registry to update the package there. + - [`npm version`](https://docs.npmjs.com/cli/v6/commands/npm-version) / [`yarn version`](https://yarnpkg.com/cli/version) is useful to create tags. + - You could also add `"postversion": "git push --follow-tags"` to **package.json** file to push it automatically after `npm` or `yarn` `version`. (for `yarn version` only: because `yarn version` doesn't check whether there are uncommitted changes, you can add `"preversion": "git diff-index --quiet HEAD --"` to **package.json**) -Apparently, you have to change the version number in order to publish a new version to the registries. You can unpublish a version or the whole package but can never re-publish the same version under the same name. +For npm registry: you can unpublish a version or the whole package but can never re-publish the same version under the same name. If you want to modify the description / README on the npm package page, you have to publish a new version. You can modify the description on GitHub Packages without publishing. diff --git a/package-lock.json b/package-lock.json index b8619cf..d5cb3ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2311,9 +2311,9 @@ } }, "electron-to-chromium": { - "version": "1.3.657", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.657.tgz", - "integrity": "sha512-/9ROOyvEflEbaZFUeGofD+Tqs/WynbSTbNgNF+/TJJxH1ePD/e6VjZlDJpW3FFFd3nj5l3Hd8ki2vRwy+gyRFw==", + "version": "1.3.659", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.659.tgz", + "integrity": "sha512-VPc1LcvuQYGjam6k7JcB6uJFTMo2YNlJ6rSbwbxApZQdow7X81kh/vDB6LB5B8DNmvkbKnpZkLmpKmnvoKA+Gw==", "dev": true }, "emittery": {