Skip to content

Commit

Permalink
Add alpha NPM workflow and minor updates to existing
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Hinek <[email protected]>
  • Loading branch information
frankhinek committed Jun 8, 2023
1 parent 6e26796 commit 65027c5
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 28 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/alpha-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Alpha to NPM Registry

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Allow only one concurrent deployment,but do NOT cancel in-progress runs as
# we want to allow these alpha deployments to complete.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read
id-token: write # necessary for NPM provenance

jobs:
publish-alpha-npm:
name: NPM Publish
runs-on: ubuntu-latest

strategy:
matrix:
package:
[
"crypto",
"dids",
"web5",
"web5-agent",
"web5-proxy-agent",
"web5-user-agent",
]

steps:
- name: Checkout source
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Set up Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Install latest npm
run: npm install -g npm@latest

# Note - this is not required but it gives a clean failure prior to attempting a release if the GH workflow runner is not authenticated with NPMjs.com
- name: Verify NPM token is authenticated with NPMjs.com
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
run: npm whoami

- name: Fetch the version in the GitHub repo's package.json file
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
run: |
cd packages/${{ matrix.package }}
REPO_VERSION=$(node -p "require('./package.json').version")
echo "REPO_VERSION=$REPO_VERSION" >> $GITHUB_ENV
echo "Repo Version: $REPO_VERSION"
shell: bash

- name: Generate the alpha version string
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
run: |
cd packages/${{ matrix.package }}
SHORT_COMMIT_SHA=$(git rev-parse --short HEAD)
YYYYMMDD=$(date +'%Y%m%d')
ALPHA_VERSION="${{ env.REPO_VERSION }}-alpha-$YYYYMMDD-$SHORT_COMMIT_SHA"
echo "ALPHA_VERSION=$ALPHA_VERSION" >> $GITHUB_ENV
echo "Alpha Version: $ALPHA_VERSION"
shell: bash

- name: Install dependencies
run: npm ci

- name: Build all workspace packages
run: npm run build

- name: Publish @tbd54566975/${{ matrix.package }}@${{ env.ALPHA_VERSION }}
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
run: |
cd packages/${{ matrix.package }}
npm version ${{ env.ALPHA_VERSION }} --no-git-tag-version
npm publish --tag alpha --no-git-tag-version --access public --provenance
shell: bash
26 changes: 0 additions & 26 deletions .github/workflows/create-site-issue.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/notify-dev-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Create Dev Site Issue On Release

on:
release:
types: [created]

# Allow only one concurrent deployment,but do NOT cancel in-progress runs as
# we want to allow issue creation to complete.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
create-issue:
runs-on: ubuntu-latest

steps:
- name: Create Issue
uses: actions/github-script@v6
with:
github-token: ${{ secrets.DOCS_PAT }} # Assuming 'PAT' is your Personal Access Token stored as a secret
script: |
const issueTitle = `Web5 JS ${context.payload.release.tag_name} released`;
const issueBody = `Please check the TBD Developer Site docs for compatibility with the release and update accordingly.\n\n[Click to view release notes](${context.payload.release.html_url})`;
const labels = ['triage', 'BLOCKER'];
github.rest.issues.create({
owner: 'TBD54566975',
repo: 'developer.tbd.website',
title: issueTitle,
body: issueBody,
labels: labels
});
8 changes: 6 additions & 2 deletions .github/workflows/release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ on:
release:
types: [created]

concurrency: ${{ github.workflow }}-${{ github.ref }}
# Allow only one concurrent deployment,but do NOT cancel in-progress runs as
# we want to allow these release deployments to complete.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read
id-token: write
id-token: write # necessary for NPM provenance

jobs:
publish-npm:
Expand Down

0 comments on commit 65027c5

Please sign in to comment.