Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions .github/workflows/cd-teardown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ env:
CI: true
jobs:
unpublish-npm:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
if: github.event.ref_type == 'branch'
steps:
- name: Prepare for unpublication from npm
uses: actions/setup-node@v2.5.0
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Determine npm tag
# Remove non-alphanumeric characters
# See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: echo "TAG_SLUG=$(echo "${{ github.event.ref }}" | tr -cd '[:alnum:]-')" >> $GITHUB_ENV
- name: Remove npm tag for the deleted branch
run: |
export EXISTING_TAGS=$(npm dist-tag ls @inrupt/solid-client | grep --count $TAG_SLUG)
# Unfortunately GitHub Actions does not currently let us do something like
# if: secrets.NPM_TOKEN != ''
# so simply skip the command if the env var is not set:
if [ -n $NODE_AUTH_TOKEN ] && [ $EXISTING_TAGS -eq 1 ]; then npm dist-tag rm @inrupt/solid-client $TAG_SLUG; fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: echo "Package tag [$TAG_SLUG] unpublished."
- name: Prepare for unpublication from npm
uses: actions/setup-node@v3
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- name: Determine npm tag
# Remove non-alphanumeric characters
# See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: echo "TAG_SLUG=$(echo "${{ github.event.ref }}" | tr -cd '[:alnum:]-')" >> $GITHUB_ENV
- name: Remove npm tag for the deleted branch
run: |
export EXISTING_TAGS=$(npm dist-tag ls @inrupt/solid-client | grep --count $TAG_SLUG)
# Unfortunately GitHub Actions does not currently let us do something like
# if: secrets.NPM_TOKEN != ''
# so simply skip the command if the env var is not set:
if [ -n $NODE_AUTH_TOKEN ] && [ $EXISTING_TAGS -eq 1 ]; then npm dist-tag rm @inrupt/solid-client $TAG_SLUG; fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: echo "Package tag [$TAG_SLUG] unpublished."
229 changes: 115 additions & 114 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,133 +3,134 @@ name: CD
on:
push:
branches:
- '**'
- "**"
tags-ignore:
# Only create preview releases for branches
# (the `release` workflow creates actual releases for version tags):
- '**'
# Only create preview releases for branches
# (the `release` workflow creates actual releases for version tags):
- "**"

env:
CI: true
jobs:
prepare-deployment:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
outputs:
tag-slug: ${{ steps.determine-npm-tag.outputs.tag-slug }}
deployment-id: ${{ fromJson(steps.create-deployment.outputs.data || '{}').id || 'Skipped for Dependabot' }}
steps:
- name: Create GitHub Deployment
if: github.actor != 'dependabot[bot]'
id: create-deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/:repository/deployments
repository: ${{ github.repository }}
ref: ${{ github.sha }}
environment: review
transient_environment: true
auto_merge: false
mediaType: '{"previews": ["flash", "ant-man"]}'
# The deployment runs in parallel with CI, so status checks will never have succeeded yet:
required_contexts: '[]'
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Determine npm tag
if: github.actor != 'dependabot[bot]'
id: determine-npm-tag
run: |
# Remove non-alphanumeric characters
# See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
echo "::set-output name=tag-slug::$(echo ${GITHUB_REF#refs/heads/} | tr -cd '[:alnum:]-')"
- name: Create GitHub Deployment
if: github.actor != 'dependabot[bot]'
id: create-deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/:repository/deployments
repository: ${{ github.repository }}
ref: ${{ github.sha }}
environment: review
transient_environment: true
auto_merge: false
mediaType: '{"previews": ["flash", "ant-man"]}'
# The deployment runs in parallel with CI, so status checks will never have succeeded yet:
required_contexts: "[]"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Determine npm tag
if: github.actor != 'dependabot[bot]'
id: determine-npm-tag
run: |
# Remove non-alphanumeric characters
# See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
echo "::set-output name=tag-slug::$(echo ${GITHUB_REF#refs/heads/} | tr -cd '[:alnum:]-')"

publish-npm:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: [prepare-deployment]
outputs:
version-nr: ${{ steps.determine-npm-version.outputs.version-nr }}
steps:
- uses: actions/checkout@v2.4.0
- name: Mark GitHub Deployment as in progress
if: github.actor != 'dependabot[bot]'
id: start-deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/:repository/deployments/:deployment/statuses
repository: ${{ github.repository }}
deployment: ${{ needs.prepare-deployment.outputs.deployment-id }}
environment: review
description: "Publishing to npm tag [${{ needs.prepare-deployment.outputs.tag-slug }}]…"
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
state: in_progress
mediaType: '{"previews": ["flash", "ant-man"]}'
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/setup-node@v2.5.0
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Prepare prerelease version
if: github.actor != 'dependabot[bot]'
id: determine-npm-version
run: |
git config user.name $GITHUB_ACTOR
git config user.email gh-actions-${GITHUB_ACTOR}@github.com
# Unfortunately re-running a job does not change its run ID nor run number.
# To prevent re-releasing the same version when re-running the CD job,
# we incorporate a timestamp in the prerelease version:
TIMESTAMP=$(date --utc +%s)
# Make sure the prerelease is tagged with the branch name, and that they are sorted by build:
VERSION_NR=$(npm version prerelease --preid=$TAG_SLUG-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-$TIMESTAMP)
echo "::set-output name=version-nr::$VERSION_NR"
env:
TAG_SLUG: ${{ needs.prepare-deployment.outputs.tag-slug }}
- run: npm ci
- name: Publish an npm tag for this branch
if: github.actor != 'dependabot[bot]'
run: |
# Unfortunately GitHub Actions does not currently let us do something like
# if: secrets.NPM_TOKEN != ''
# so simply skip the command if the env var is not set:
if [ -z $NODE_AUTH_TOKEN ]; then echo "No npm token defined; package not published."; fi
if [ -n $NODE_AUTH_TOKEN ]; then npm publish --access public --tag "$TAG_SLUG"; fi
if [ -n $NODE_AUTH_TOKEN ]; then echo "Package published. To install, run:"; fi
if [ -n $NODE_AUTH_TOKEN ]; then echo ""; fi
if [ -n $NODE_AUTH_TOKEN ]; then echo " npm install @inrupt/solid-ui-react@$TAG_SLUG"; fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
TAG_SLUG: ${{ needs.prepare-deployment.outputs.tag-slug }}
- name: Mark GitHub Deployment as successful
if: github.actor != 'dependabot[bot]'
uses: octokit/request-action@v2.x
with:
route: POST /repos/:repository/deployments/:deployment/statuses
repository: ${{ github.repository }}
deployment: ${{ needs.prepare-deployment.outputs.deployment-id }}
environment: review
environment_url: 'https://www.npmjs.com/package/@inrupt/solid-ui-react/v/${{ needs.prepare-deployment.outputs.tag-slug }}'
description: "Published to npm. To install, run: npm install @inrupt/solid-ui-react@${{ needs.prepare-deployment.outputs.tag-slug }}"
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
mediaType: '{"previews": ["flash", "ant-man"]}'
state: success
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Mark GitHub Deployment as failed
uses: octokit/request-action@v2.x
if: failure() && github.actor != 'dependabot[bot]'
with:
route: POST /repos/:repository/deployments/:deployment/statuses
repository: ${{ github.repository }}
deployment: ${{ needs.prepare-deployment.outputs.deployment-id }}
environment: review
description: "Publication to npm failed. Review the GitHub Actions log for more information."
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
mediaType: '{"previews": ["flash", "ant-man"]}'
state: failure
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Waiting for npm CDNs to update...
if: github.actor != 'dependabot[bot]'
run: |
echo "Giving npm some time to make the newly-published package available…"
sleep 5m
echo "Done — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK."
- uses: actions/checkout@v3
- name: Mark GitHub Deployment as in progress
if: github.actor != 'dependabot[bot]'
id: start-deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/:repository/deployments/:deployment/statuses
repository: ${{ github.repository }}
deployment: ${{ needs.prepare-deployment.outputs.deployment-id }}
environment: review
description: "Publishing to npm tag [${{ needs.prepare-deployment.outputs.tag-slug }}]…"
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
state: in_progress
mediaType: '{"previews": ["flash", "ant-man"]}'
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/setup-node@v3
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
cache: npm
- name: Prepare prerelease version
if: github.actor != 'dependabot[bot]'
id: determine-npm-version
run: |
git config user.name $GITHUB_ACTOR
git config user.email gh-actions-${GITHUB_ACTOR}@github.com
# Unfortunately re-running a job does not change its run ID nor run number.
# To prevent re-releasing the same version when re-running the CD job,
# we incorporate a timestamp in the prerelease version:
TIMESTAMP=$(date --utc +%s)
# Make sure the prerelease is tagged with the branch name, and that they are sorted by build:
VERSION_NR=$(npm version prerelease --preid=$TAG_SLUG-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-$TIMESTAMP)
echo "::set-output name=version-nr::$VERSION_NR"
env:
TAG_SLUG: ${{ needs.prepare-deployment.outputs.tag-slug }}
- run: npm ci
- name: Publish an npm tag for this branch
if: github.actor != 'dependabot[bot]'
run: |
# Unfortunately GitHub Actions does not currently let us do something like
# if: secrets.NPM_TOKEN != ''
# so simply skip the command if the env var is not set:
if [ -z $NODE_AUTH_TOKEN ]; then echo "No npm token defined; package not published."; fi
if [ -n $NODE_AUTH_TOKEN ]; then npm publish --access public --tag "$TAG_SLUG"; fi
if [ -n $NODE_AUTH_TOKEN ]; then echo "Package published. To install, run:"; fi
if [ -n $NODE_AUTH_TOKEN ]; then echo ""; fi
if [ -n $NODE_AUTH_TOKEN ]; then echo " npm install @inrupt/solid-ui-react@$TAG_SLUG"; fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
TAG_SLUG: ${{ needs.prepare-deployment.outputs.tag-slug }}
- name: Mark GitHub Deployment as successful
if: github.actor != 'dependabot[bot]'
uses: octokit/request-action@v2.x
with:
route: POST /repos/:repository/deployments/:deployment/statuses
repository: ${{ github.repository }}
deployment: ${{ needs.prepare-deployment.outputs.deployment-id }}
environment: review
environment_url: "https://www.npmjs.com/package/@inrupt/solid-ui-react/v/${{ needs.prepare-deployment.outputs.tag-slug }}"
description: "Published to npm. To install, run: npm install @inrupt/solid-ui-react@${{ needs.prepare-deployment.outputs.tag-slug }}"
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
mediaType: '{"previews": ["flash", "ant-man"]}'
state: success
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Mark GitHub Deployment as failed
uses: octokit/request-action@v2.x
if: failure() && github.actor != 'dependabot[bot]'
with:
route: POST /repos/:repository/deployments/:deployment/statuses
repository: ${{ github.repository }}
deployment: ${{ needs.prepare-deployment.outputs.deployment-id }}
environment: review
description: "Publication to npm failed. Review the GitHub Actions log for more information."
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
mediaType: '{"previews": ["flash", "ant-man"]}'
state: failure
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Waiting for npm CDNs to update...
if: github.actor != 'dependabot[bot]'
run: |
echo "Giving npm some time to make the newly-published package available…"
sleep 5m
echo "Done — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK."
50 changes: 29 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,46 @@ env:
CI: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm run audit --production
- run: npm run audit-licenses
- run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Available OS's: https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
os: [ubuntu-20.04, windows-2019]
node-version: [16.x, 14.x, 12.x]
os: [ubuntu-latest, windows-latest]
node-version: [16.x, 14.x]
steps:
- uses: actions/checkout@v2.4.0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.5.0
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v2.1.7
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-node${{ runner.node-version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
cache: npm
- run: npm ci
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- run: npm run lint
- run: npm run test
- run: npm run audit --production
- run: npm run audit-licenses
- run: npm run build
- name: Archive code coverage results
uses: actions/upload-artifact@v2.3.0
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: coverage
- name: Archive production artifacts
uses: actions/upload-artifact@v2.3.0
with:
name: dist
path: dist
Loading