From b7a26057445f805be6e9d6c9c25bbb3123125fe9 Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Wed, 19 Oct 2022 21:46:42 +0200 Subject: [PATCH] ci: remove continuous delivery workflows These were poorly implemented and resulted in us publishing thousands of versions of our packages --- .github/workflows/cd-teardown.yml | 30 ------- .github/workflows/cd.yml | 136 ------------------------------ .github/workflows/release.yml | 76 +---------------- 3 files changed, 1 insertion(+), 241 deletions(-) delete mode 100644 .github/workflows/cd-teardown.yml delete mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd-teardown.yml b/.github/workflows/cd-teardown.yml deleted file mode 100644 index 9c770ea2..00000000 --- a/.github/workflows/cd-teardown.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: CD - -on: delete - -env: - CI: true -jobs: - unpublish-npm: - runs-on: ubuntu-latest - if: github.event.ref_type == 'branch' - steps: - - 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.INRUPT_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.INRUPT_NPM_TOKEN }} - - run: echo "Package tag [$TAG_SLUG] unpublished." diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index 7f6520f2..00000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,136 +0,0 @@ -name: CD - -on: - push: - branches: - - "**" - tags-ignore: - # Only create preview releases for branches - # (the `release` workflow creates actual releases for version tags): - - "**" - -env: - CI: true -jobs: - prepare-deployment: - 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:]-')" - - publish-npm: - runs-on: ubuntu-latest - needs: [prepare-deployment] - outputs: - version-nr: ${{ steps.determine-npm-version.outputs.version-nr }} - steps: - - 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.INRUPT_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.INRUPT_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." diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ab4fc1c..ea77ca9f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,46 +8,10 @@ on: env: CI: true jobs: - prepare-deployment: - runs-on: ubuntu-latest - outputs: - deployment-id: ${{ fromJson(steps.create-deployment.outputs.data).id }} - steps: - - name: Create GitHub Deployment - 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 }}" - publish-npm: runs-on: ubuntu-latest - needs: [prepare-deployment] steps: - uses: actions/checkout@v3 - - name: Mark GitHub Deployment as in progress - 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 [${GITHUB_REF#refs/tags/v}]…" - 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 }}" - name: Prepare for publication to npm uses: actions/setup-node@v3 with: @@ -55,44 +19,6 @@ jobs: registry-url: "https://registry.npmjs.org" cache: npm - run: npm ci - - name: Publish to npm - run: | - npm publish --access public - echo "Package published. To install, run:" - echo "" - echo " npm install @inrupt/solid-ui-react" + - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.INRUPT_NPM_TOKEN }} - - name: Mark GitHub Deployment as successful - 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/${GITHUB_REF#refs/tags/v}" - description: "Published to npm. To install, run: npm install @inrupt/solid-ui-react@${GITHUB_REF#refs/tags/v}" - 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() - 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... - run: | - echo "Giving npm some time to make the newly-published package available…" - sleep 5m - echo "Done waiting — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK."