-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: changing npm publish pipeline (#60)
* feat: changing npm publish pipeline * feat: changing npm publish pipeline
- Loading branch information
1 parent
095b8f7
commit 9b423ed
Showing
3 changed files
with
158 additions
and
43 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
################################################################################ | ||
# DO NOT EDIT THIS FILE (Auto-Generated) # | ||
# Contents of this file were generated by https://github.com/parcelLab/.github # | ||
# Changes to this file may be overwritten. # | ||
################################################################################ | ||
name: ~Lib / NPM Publish | ||
on: | ||
workflow_call: | ||
inputs: | ||
access: | ||
required: false | ||
description: The package access ('restricted' or 'public') | ||
default: restricted | ||
type: string | ||
botEmail: | ||
required: false | ||
description: The email of the bot that will appear in the GitOps commit | ||
default: [email protected] | ||
type: string | ||
botName: | ||
required: false | ||
description: The name of the bot that will appear in the GitOps commit | ||
default: parcellab-dev-bot | ||
type: string | ||
buildBeforePublish: | ||
required: false | ||
description: Build the package before publishing | ||
default: true | ||
type: string | ||
defaultBranch: | ||
required: false | ||
description: The default branch | ||
default: main | ||
type: string | ||
nodeVersion: | ||
required: false | ||
description: The node version to provide (e.g. `lts/*`, `18`, `18.4`...) | ||
default: latest | ||
type: string | ||
scope: | ||
required: false | ||
description: The npm organization (defaults to @parcellab) | ||
default: "@parcellab" | ||
type: string | ||
version: | ||
required: true | ||
description: The version to publish (without 'v') | ||
type: string | ||
secrets: | ||
githubAuthToken: | ||
required: false | ||
npmjsAuthToken: | ||
required: false | ||
jobs: | ||
npm-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout current git repository | ||
uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of REPO_ACCESS_TOKEN | ||
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository | ||
- name: Use Node.js with Github Packages as registry url | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ inputs.nodeVersion }} | ||
registry-url: https://npm.pkg.github.com | ||
scope: ${{ inputs.scope }} | ||
- name: Install npm dependencies | ||
run: npm i | ||
env: | ||
NPM_GITHUB_TOKEN: ${{ secrets.PACKAGES_READ_TOKEN }} | ||
- if: inputs.buildBeforePublishing | ||
name: Run build | ||
run: npm run build | ||
- name: Update package.json version to ${{ inputs.version }} | ||
uses: mikefarah/[email protected] | ||
with: | ||
cmd: | | ||
yq e '.version = "${{ inputs.version }}"' -i package.json -j | ||
- name: Commit new package.json version | ||
run: | | ||
git config --local user.email "${{ inputs.botEmail }}" | ||
git config --local user.name "${{ inputs.botName }}" | ||
git commit -m "chore: set version ${{ inputs.version }} [skip ci]" -a | ||
- name: Push changes to current git repository | ||
uses: ad-m/[email protected] | ||
with: | ||
github_token: ${{ secrets.githubAuthToken }} | ||
branch: ${{ inputs.defaultBranch }} | ||
- name: Publish NPM package | ||
run: npm publish --access ${{ inputs.access }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.githubAuthToken }} | ||
- if: inputs.access == 'public' | ||
name: Use Node.js with NPMjs as registry url | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ inputs.nodeVersion }} | ||
registry-url: https://registry.npmjs.org | ||
scope: ${{ inputs.scope }} | ||
- if: inputs.access == 'public' | ||
name: Publish NPM package | ||
run: npm publish --access ${{ inputs.access }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.npmjsAuthToken }} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
################################################################################ | ||
# DO NOT EDIT THIS FILE (Auto-Generated) - COPY IT! # | ||
# # | ||
# Contents of this file were generated by https://github.com/parcelLab/.github # | ||
# Changes to this file may be overwritten. # | ||
# # | ||
# Copy this file into the repo .github/workflows folder and edit it based on # | ||
# your needs to create a new workflow. Rename it to `publish.yaml`. # | ||
################################################################################ | ||
name: Publish | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: The version to publish (without 'v', e.g. 1.0.0) | ||
required: true | ||
jobs: | ||
version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.load_version.outputs.version }} | ||
steps: | ||
- name: Load version | ||
id: load_version | ||
run: | | ||
if [ "$GITHUB_EVENT_NAME" = 'workflow_dispatch' ] | ||
then | ||
VERSION="${{ github.event.inputs.version }}" | ||
else | ||
if [ "$GITHUB_EVENT_NAME" = 'release' ] | ||
then | ||
TAG_NAME="${{ github.event.release.tag_name }}" | ||
else | ||
TAG_NAME="${{ github.ref }}" | ||
fi | ||
CLEAN_TAG=${TAG_NAME##*/} | ||
VERSION=${CLEAN_TAG//v} | ||
fi | ||
echo "::set-output name=version::$VERSION" | ||
publish: | ||
needs: version | ||
uses: ./.github/workflows/_npm-publish.yaml | ||
with: | ||
# access: public # For public packages | ||
# buildBeforePublish: false # For packages that do not require a build step | ||
version: ${{ needs.version.outputs.version }} | ||
secrets: | ||
githubAuthToken: ${{ secrets.REPO_ACCESS_TOKEN }} | ||
# npmjsAuthToken: ${{ secrets.NPM_TOKEN }} # For public packages |