Skip to content

Commit

Permalink
wiring up gh workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfoyle committed Apr 2, 2024
1 parent 3ec8563 commit 87f75c1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/deprecate_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: deprecate_release

on:
workflow_dispatch:
inputs:
commitHash:
required: true
type: string
deprecationMessage:
required: true
type: string

jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # version 3.6.0
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/install_with_cache
deprecate_release:
needs:
- install
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # version 3.6.0
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/restore_install_cache
- name: Deprecate release versions
run: npx tsx scripts deprecate_release.ts --commit-hash ${{ inputs.commitHash }} --deprecation-message ${{ inputs.deprecationMessage }}
20 changes: 11 additions & 9 deletions scripts/deprecate_release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import * as fsp from 'fs/promises';
* This script deprecates a set of package versions that were released by a single release commit.
*
* The steps that it takes are
* 1. Verify that the input commit-hash is a valid release commit
* 2. Find the git tags associated with that commit. These are the package versions that need to be deprecated
* 3. Find the release commit _before_ the input commit-hash
* 4. Find the git tags associated with the previous release commit. These are the package versions that need to be marked as "latest" (or whatever the dist-tag for the release was)
* 5. Create a rollback PR that resets the .changeset directory to its state at the previous release
* 1. Verifies that the input commit-hash is a valid release commit
* 2. Finds the git tags associated with that commit. These are the package versions that need to be deprecated
* 3. Finds the release commit _before_ the input commit-hash
* 4. Finds the git tags associated with the previous release commit. These are the package versions that need to be marked as "latest" (or whatever the dist-tag for the release is)
* 5. Creates a rollback PR that resets the .changeset directory to its state at the previous release
* 6. Marks the previous package versions as latest
* 7. Marks the current package versions as deprecated
*/
Expand Down Expand Up @@ -203,14 +203,16 @@ for (const packageVersion of packageVersionsToRestore) {
console.log(
`Restoring dist tag "${distTag}" to package version ${packageVersion}`
);
await $({ stdio: 'inherit' })`npm dist-tag add ${packageVersion} ${distTag}`;
// TODO uncomment but testing in "dry-run" mode for now
// await $({ stdio: 'inherit' })`npm dist-tag add ${packageVersion} ${distTag}`;
console.log(`Done!${EOL}`);
}

for (const packageVersion of packageVersionsToDeprecate) {
console.log(`Deprecating package version ${packageVersion}`);
await $({
stdio: 'inherit',
})`npm deprecate ${packageVersion} "${deprecationMessage}"`;
// TODO uncomment but testing in "dry-run" mode for now
// await $({
// stdio: 'inherit',
// })`npm deprecate ${packageVersion} "${deprecationMessage}"`;
console.log(`Done!${EOL}`);
}

0 comments on commit 87f75c1

Please sign in to comment.