-
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
1 parent
1036598
commit e2bd937
Showing
2 changed files
with
85 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,49 @@ | ||
name: Publish package | ||
|
||
on: workflow_dispatch | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
publish_package: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Bun | ||
uses: oven-sh/setup-bun@v1 | ||
|
||
- id: changelog | ||
name: Generate changelog | ||
run: bun scripts/generate-changelog.ts | ||
|
||
- name: Install modules | ||
run: bun install | ||
|
||
- name: Install Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
registry-url: "https://registry.npmjs.org" | ||
scope: "@gramio" | ||
|
||
- name: Publish package | ||
run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: GitHub Release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: v${{ steps.changelog.outputs.version }} | ||
name: v${{ steps.changelog.outputs.version }} | ||
body: ${{ steps.changelog.outputs.changelog }} | ||
draft: false | ||
prerelease: false | ||
generateReleaseNotes: true |
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,36 @@ | ||
import { execSync } from "node:child_process"; | ||
import { randomUUID } from "node:crypto"; | ||
import { appendFileSync } from "node:fs"; | ||
import { EOL } from "node:os"; | ||
|
||
function getLatestTag() { | ||
try { | ||
return execSync("git describe --abbrev=0 --tags").toString().trim(); | ||
} catch (e) { | ||
console.warn(e); | ||
return execSync("git rev-list --max-parents=0 HEAD").toString().trim(); | ||
} | ||
} | ||
|
||
const commits = execSync( | ||
`git log ${getLatestTag()}..HEAD --pretty="format:%s%b"`, | ||
) | ||
.toString() | ||
.trim() | ||
.split("\n") | ||
.reverse(); | ||
|
||
console.log(getLatestTag(), commits); | ||
|
||
const version = execSync("npm pkg get version").toString().replace(/"/gi, ""); | ||
|
||
const delimiter = `---${randomUUID()}---${EOL}`; | ||
|
||
if (process.env.GITHUB_OUTPUT) | ||
appendFileSync( | ||
process.env.GITHUB_OUTPUT, | ||
`changelog<<${delimiter}${commits.join( | ||
EOL.repeat(2), | ||
)}${EOL}${delimiter}version=${version}${EOL}`, | ||
); | ||
else console.log("Not github actions"); |