From 65027c5338a63508839e93c7d4594140c12f1bc5 Mon Sep 17 00:00:00 2001 From: Frank Hinek Date: Wed, 7 Jun 2023 15:22:16 -0400 Subject: [PATCH] Add alpha NPM workflow and minor updates to existing Signed-off-by: Frank Hinek --- .github/workflows/alpha-npm.yml | 88 +++++++++++++++++++++++++ .github/workflows/create-site-issue.yml | 26 -------- .github/workflows/notify-dev-site.yml | 32 +++++++++ .github/workflows/release-npm.yml | 8 ++- 4 files changed, 126 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/alpha-npm.yml delete mode 100644 .github/workflows/create-site-issue.yml create mode 100644 .github/workflows/notify-dev-site.yml diff --git a/.github/workflows/alpha-npm.yml b/.github/workflows/alpha-npm.yml new file mode 100644 index 000000000..46a0cdeb4 --- /dev/null +++ b/.github/workflows/alpha-npm.yml @@ -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 diff --git a/.github/workflows/create-site-issue.yml b/.github/workflows/create-site-issue.yml deleted file mode 100644 index b73323f8f..000000000 --- a/.github/workflows/create-site-issue.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Create Dev site Issue On Release - -on: - release: - types: [created] - -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 = `New web5 release ${context.payload.release.tag_name} just cut`; - const issueBody = `Please check the api docs etc for compatibility with the release. Here is the [link to 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 - }); diff --git a/.github/workflows/notify-dev-site.yml b/.github/workflows/notify-dev-site.yml new file mode 100644 index 000000000..b3a930be6 --- /dev/null +++ b/.github/workflows/notify-dev-site.yml @@ -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 + }); diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 70d67c44f..e69dad97a 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -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: