Skip to content

v1.3.0

v1.3.0 #7

Workflow file for this run

name: NPM Publish
# Workflow: Automated NPM release on GitHub release creation
#
# Prerequisites:
# - `NPM_TOKEN` with `automation` permissions (generate at [npmjs.org](https://docs.npmjs.com/creating-and-viewing-access-tokens))
# - `NPM_TOKEN` added to GitHub Repository Secrets
on:
workflow_dispatch:
release:
types: [created]
env:
RELEASE_NODE_VERSION: "18.x" # https://nodejs.dev/en/about/releases
jobs:
publish-dry-run:
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.RELEASE_NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
- name: Cache Yarn packages
uses: actions/cache@v4
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile
- run: yarn run build
- name: Set NPM_TOKEN
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
# Docs: https://docs.npmjs.com/cli/v8/commands/npm-whoami
- run: npm whoami
id: whoami
- run: npm publish --dry-run
- run: git status
build-and-publish:
needs: [publish-dry-run]
runs-on: ubuntu-latest
environment:
name: release
url: https://www.npmjs.com/package/printify-sdk-js
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.RELEASE_NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
- name: Cache Yarn packages
uses: actions/cache@v4
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile
- run: yarn run build
- name: Create .npmrc
run: |
touch .npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
echo "registry=https://registry.npmjs.org/" >> .npmrc
echo "always-auth=true" >> .npmrc
- name: Publish NPM Package
run: npm publish --access public --userconfig .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}