-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from tiktok/chore-gh-release
chore: sparo github release
- Loading branch information
Showing
7 changed files
with
548 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Sparo GitHub Release | ||
on: | ||
push: | ||
tags: | ||
- "sparo_v*.*.*" | ||
workflow_dispatch: | ||
inputs: | ||
tag_name: | ||
description: 'Tag name for release' | ||
required: true | ||
default: '' | ||
jobs: | ||
sparo-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
token: ${{ secrets.BOT_ACCESS_TOKEN }} | ||
- name: git config email | ||
run: git config --local user.email [email protected] | ||
- name: git config name | ||
run: git config --local user.name tiktokbot | ||
- name: Extract version from tag | ||
id: extract_version | ||
run: | | ||
# Get the tag name from GITHUB_REF (e.g., refs/tags/sparo_v1.0.0) | ||
TAG_NAME="${GITHUB_REF##*/}" | ||
# Extract the version number (v1.0.0) using regex | ||
VERSION=$(echo "$TAG_NAME" | sed -E 's/^.*_v([0-9]+\.[0-9]+\.[0-9]+.*)$/\1/') | ||
echo "Extracted version: $VERSION" | ||
# Set the output for later use | ||
echo "::set-output name=version::$VERSION" | ||
- name: Generate Release Description | ||
run : node common/scripts/install-run-rush.js generate-release-description --project sparo --version ${{ steps.extract_version.outputs.version }} | ||
- name: Sparo GitHub Release | ||
uses: softprops/action-gh-release@v2 | ||
if: ${{ exists('RELEASE/SPARO.md') }} | ||
with: | ||
draft: true | ||
body_path: RELEASE/SPARO.md | ||
|
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 |
---|---|---|
|
@@ -92,3 +92,5 @@ dist-storybook | |
# Docusaurus build outputs | ||
build | ||
.docusaurus | ||
|
||
RELEASE/ |
53 changes: 53 additions & 0 deletions
53
common/autoinstallers/generate-release-description/generate.js
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,53 @@ | ||
const path = require('path'); | ||
const { RushConfiguration } = require('@rushstack/rush-sdk'); | ||
const { FileSystem } = require('@rushstack/node-core-library'); | ||
|
||
const rushConfiguration = RushConfiguration.loadFromDefaultLocation(); | ||
|
||
/** @type (args: { project: string; version: string }) => void */ | ||
function generate({project, version}) { | ||
|
||
const rushProject = rushConfiguration.getProjectByName(project); | ||
|
||
if (!rushProject) { | ||
throw new Error(`Not found project "${project}"`) | ||
} | ||
|
||
const { projectFolder } = rushProject; | ||
|
||
const changelogJsonFilePath = path.resolve(projectFolder, 'CHANGELOG.json'); | ||
|
||
if (!FileSystem.exists(changelogJsonFilePath)) { | ||
throw new Error(`Not found changelog.json at ${changelogJsonFilePath}`) | ||
} | ||
|
||
const changelogJsonFileContent = FileSystem.readFile(changelogJsonFilePath, 'utf-8'); | ||
|
||
const changelogJson = JSON.parse(changelogJsonFileContent); | ||
|
||
const changeEntry = changelogJson.entries?.find(x => x.version === version); | ||
|
||
if (!changeEntry) { | ||
throw new Error(`Not found version "${version}" info in ${changelogJsonFilePath}`) | ||
} | ||
|
||
const comments = Object.entries(changeEntry.comments).map(([_, value]) => { | ||
return value.map(x => x.comment); | ||
}).flat(); | ||
console.log('commnets', comments); | ||
|
||
const content = `### Update | ||
${comments.map(x => `- ${x}`).join('\n')} | ||
` | ||
|
||
const releaseFilePath = path.resolve(rushConfiguration.rushJsonFolder, 'RELEASE', `${project.toUpperCase()}.md`) | ||
|
||
FileSystem.writeFile(releaseFilePath, content, { | ||
ensureFolderExists: true, | ||
}); | ||
} | ||
|
||
module.exports = { | ||
generate | ||
} |
20 changes: 20 additions & 0 deletions
20
common/autoinstallers/generate-release-description/index.js
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,20 @@ | ||
const yargs = require('yargs'); | ||
const { generate } = require('./generate'); | ||
|
||
const args = yargs(process.argv.slice(2)) | ||
.version(false) | ||
.option('project', { | ||
demandOption: true, | ||
describe: 'A rush project name', | ||
type: 'string' | ||
}) | ||
.option('version', { | ||
demandOption: true, | ||
describe: "Version number", | ||
type: 'string' | ||
}).argv; | ||
|
||
generate(args); | ||
|
||
|
||
|
10 changes: 10 additions & 0 deletions
10
common/autoinstallers/generate-release-description/package.json
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,10 @@ | ||
{ | ||
"name": "generate-release-description", | ||
"version": "1.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@rushstack/node-core-library": "^5.9.0", | ||
"@rushstack/rush-sdk": "^5.140.0", | ||
"yargs": "^17.7.2" | ||
} | ||
} |
Oops, something went wrong.