Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(samsungknox-scripts): add create release #32

Merged
merged 1 commit into from
Feb 29, 2024
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
5 changes: 5 additions & 0 deletions .changeset/few-falcons-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@samsungknox/scripts": patch
---

Added create release tag script and workflow. From now on, the release version will be based on the root package version.
53 changes: 53 additions & 0 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Create Release

on:
pull_request:
branches:
- develop
types: [closed]
workflow_dispatch:
inputs:
force_deploy:
type: boolean
description: '(Force Deploy) If you need force deploy, change this option to true.'
required: true
default: false

jobs:
create-release:
if: >
(github.event.pull_request.merged == true && github.head_ref == 'changeset-release/main') ||
(inputs.force_deploy == 'true')
name: Create Release Note
runs-on: [self-hosted, linux, x64]
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
with:
version: 8

- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: pnpm i

- name: Create a release tag
working-directory: scripts
id: create_tag
run: pnpm script:create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create a release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.create_tag.outputs.tag_name }}
body_path: docs/releases/${{ steps.create_tag.outputs.tag_name }}-changelog.md
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"build:production": "NODE_ENV=production tsup-node",
"build:watch": "tsup-node --watch",
"postinstall": "pnpm build:production",
"script:create-release": "node ./dist/changeset/scripts/create-release.js"
"script:create-release": "node ./dist/scripts/create-release.js"
},
"devDependencies": {
"@actions/core": "1.3.0",
Expand Down
6 changes: 3 additions & 3 deletions scripts/src/changeset/scripts/create-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ async function main(): Promise<void> {
const commitSha: string = process.env.GITHUB_SHA;
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });

const releaseVersion = await getRootPackageJsonMetadata();
const tagName = `v${releaseVersion}`;
const { version } = await getRootPackageJsonMetadata();
const tagName = `v${version}`;

log.debug(`tag_name=${tagName}${EOL}`);
log.action(`Creating release tag ${tagName} at ${commitSha}`);
Expand All @@ -59,7 +59,7 @@ async function main(): Promise<void> {
log.info(`Successfully! release tag ${tagName} at ${commitSha}`);

await fs.appendFile(process.env.GITHUB_OUTPUT, `tag_name=${tagName}${EOL}`);
await fs.appendFile(process.env.GITHUB_OUTPUT, `version=${releaseVersion}${EOL}`);
await fs.appendFile(process.env.GITHUB_OUTPUT, `version=${version}${EOL}`);
}

main().catch((error) => {
Expand Down
Loading