-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
480 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = async ({ github, context, inputs }) => { | ||
const draftTagName = `unreleased[${inputs.branchName}]`; | ||
|
||
const releases = await github.rest.repos.listReleases({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
|
||
const release = releases.data.find( | ||
(release) => release.tag_name == draftTagName && release.draft, | ||
); | ||
if (!release) { | ||
throw new Error("Draft release not found!"); | ||
} | ||
|
||
console.log("Updating the draft release..."); | ||
github.rest.repos.updateRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: release.id, | ||
name: inputs.tagName, | ||
tag_name: inputs.tagName, | ||
draft: false, | ||
prerelease: true, | ||
}); | ||
|
||
return release.id; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: "Release" | ||
description: "Release the pre-release release" | ||
|
||
inputs: | ||
release_id: | ||
description: "The id of the target release" | ||
required: true | ||
tag_name: | ||
description: "The release version tag" | ||
required: true | ||
npm_auth_token: | ||
description: "The NPM authentication token" | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Release the package | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const script = require('${{ github.action_path }}/script.js') | ||
return await script({ | ||
github, | ||
context, | ||
inputs: { | ||
releaseId: '${{ inputs.release_id }}', | ||
tagName: '${{ inputs.tag_name }}', | ||
} | ||
}) | ||
# - name: Unpublish the beta versions | ||
# shell: bash | ||
# env: | ||
# NODE_AUTH_TOKEN: ${{ inputs.npm_auth_token }} | ||
# MAJOR_VERSION: ${{ inputs.tag_name.split('.')[0] }} | ||
# run: ${{ github.action_path }}/unpublish-beta-versions.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module.exports = async ({ github, context, inputs }) => { | ||
const majorVersion = inputs.tagName.split(".")[0]; | ||
|
||
// Get current release | ||
const { data: release } = await github.rest.repos.getRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: inputs.releaseId, | ||
}); | ||
|
||
console.log("Updating release tag..."); | ||
await github.rest.repos.updateRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: release.id, | ||
name: inputs.tagName, | ||
tag_name: inputs.tagName, | ||
draft: false, | ||
prerelease: false, | ||
}); | ||
|
||
// Cleanup beta releases | ||
console.log("Cleaning up beta releases..."); | ||
const { data: releases } = await github.rest.repos.listReleases({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
|
||
for (const release of releases) { | ||
if ( | ||
release.tag_name.startsWith(`${majorVersion}.`) && | ||
release.tag_name.includes("-beta") | ||
) { | ||
console.log(`Deleting beta release: ${release.tag_name}`); | ||
await github.rest.repos.deleteRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: release.id, | ||
}); | ||
} | ||
} | ||
|
||
// Cleanup beta tags | ||
console.log("Cleaning up beta tags..."); | ||
const { data: tags } = await github.rest.repos.listTags({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
for (const tag of tags) { | ||
if (tag.name.startsWith(`${majorVersion}.`) && tag.name.includes("-beta")) { | ||
console.log(`Deleting beta tag: ${tag.name}`); | ||
await github.rest.git.deleteRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `refs/tags/${tag.name}`, | ||
}); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$MAJOR_VERSION" ]; then | ||
echo "Error: MAJOR_VERSION environment variable is not set" | ||
exit 1 | ||
fi | ||
|
||
# Get all versions and store them in an array | ||
versions=($(npm view @mtrdesign/krait-ui versions | tr -d "'[]," | tr " " "\n")) | ||
|
||
# Loop through each version | ||
for version in "${versions[@]}"; do | ||
# Check if version starts with provided major version and contains "beta" | ||
if [[ $version =~ ^${MAJOR_VERSION}\. && $version =~ beta ]]; then | ||
echo "Deleting version: $version" | ||
npm unpublish -f "@mtrdesign/krait-ui@$version" | ||
fi | ||
done |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.