Skip to content

Commit

Permalink
Set up GitHub provenance for npm (#12)
Browse files Browse the repository at this point in the history
* Copy over CI jobs for github provenance

* Prepare for 1.0 release
  • Loading branch information
spautz committed Apr 25, 2023
1 parent bdca3af commit b87919d
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-wasps-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'changesets-format-with-issue-links': major
---

Prepare for 1.0 release
77 changes: 77 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Prepare Release

on:
workflow_dispatch

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
pull-requests: write

jobs:
prepare-release-pr:
name: Prepare PR for release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- uses: pnpm/action-setup@v2
with:
version: 8

- run: corepack enable

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Prepare release
run: pnpm run release:prep

# @TODO
# - name: Import GPG key
# uses: crazy-max/ghaction-import-gpg@v5
# with:
# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
# passphrase: ${{ secrets.PASSPHRASE }}

- name: Create pull request
uses: peter-evans/create-pull-request@v5
with:
branch: prepare-release
commit-message: Prepare release (automated)
delete-branch: true
# @TODO
# token: ${{ secrets.PAT }}

- name: Check outputs
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
59 changes: 59 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish Release

on:
workflow_dispatch

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
id-token: write

jobs:
publish-npm:
name: Publish to NPM
runs-on: ubuntu-latest
strategy:
matrix:
package-name: [ node-library-template, react-library-template ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Node.js
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- uses: pnpm/action-setup@v2
with:
version: 8

- run: corepack enable

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Publish to NPM
run: |
cd packages/${{ matrix.package-name }}
npm publish --provenance --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

0 comments on commit b87919d

Please sign in to comment.