Skip to content

feat: add selectFirst function #1

feat: add selectFirst function

feat: add selectFirst function #1

Workflow file for this run

name: Check Pull Request
on:
pull_request:
branches: [main]
merge_group:
types: [checks_requested]
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- run: pnpm install
- run: pnpm test
validate:
if: ${{ github.event_name == 'pull_request' }}
name: Validate
runs-on: ubuntu-latest
env:
PR_TITLE: "${{ github.event.pull_request.title }}"
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: pnpm
- run: pnpm install
- name: Lint
run: pnpm lint
- name: Check PR Title
run: echo "$PR_TITLE" | pnpm -s dlx commitlint
publish-beta:
if: ${{ github.event_name == 'merge_group' }}
name: Publish Beta
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: "22.x"
cache: pnpm
- run: pnpm install
- name: Prepare Build
run: pnpm build
- name: Lint
run: pnpm lint
- name: Retrieve Stable Version
id: get-stable-version
run: |
echo "::set-output name=stable-version::v$(npm view radashi version)"
- name: Install git-cliff
run: pnpm install -g [email protected]
- name: Calculate Version
id: set-version
run: |
NEXT_VERSION=$(git-cliff --bumped-version | sed 's/.//')
BUILD_DIGEST=$(find dist package.json -type f -exec shasum -a 256 {} + | shasum -a 256 | cut -c 1-7)
echo "::set-output name=version::$NEXT_VERSION-beta.$BUILD_DIGEST"
- name: Check Version
id: check-version
run: |
if npm -s view radashi@${{ steps.set-version.outputs.version }}; then
echo "🚫 Version ${{ steps.set-version.outputs.version }} already exists"
echo "::set-output name=version-exists::true"
else
echo "🟢 Version ${{ steps.set-version.outputs.version }} is available"
echo "::set-output name=version-exists::false"
fi
- name: Generate Changelog
run: |
# The entire changelog is regenerated from the point in history at which Radashi was born.
git-cliff 2be4acf455ebec86e846854dbab57bd0bfbbceb7..HEAD -o CHANGELOG.md
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add CHANGELOG.md
# To avoid spamming the commit history, we use --amend to modify the latest commit.
git commit --amend --no-edit
git push -f
- name: Publish to NPM
run: |
npm version ${{ steps.set-version.outputs.version }} --no-git-tag-version
npm publish --tag beta --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Git Tags
run: |
TAG=v${{ steps.set-version.outputs.version }}
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag $TAG
git push origin $TAG
git tag beta -f
git push origin beta -f
- name: Comment on Pull Requests
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const headCommitSHA = context.payload.merge_group.head_sha
const baseCommitSHA = context.payload.merge_group.base_sha
console.log('Merge group identified: %s ... %s', baseCommitSHA, headCommitSHA)
const prNumbers = exec.exec(`git log --oneline ${baseCommitSHA}..${headCommitSHA} | grep -o '\\(#[0-9]\\+\\)' | cut -c 2-`).stdout.trim().split(/\r\n/)
console.log('PR numbers:', prNumbers)
for (const prNumber of prNumbers) {
const version = '${{ steps.set-version.outputs.version }}'
const body = `
A new beta version \`${version}\` has been published to NPM. :rocket:
To install:
\`\`\`sh
pnpm add radashi@${version}
\`\`\`
The \`radashi@beta\` tag also includes this PR.
<a href="https://github.com/radashi-org/radashi/compare/${{ steps.get-stable-version.outputs.stable-version }}...${headCommitSHA}">
<img src="https://github.com/radashi-org/radashi/raw/main/img/changes-button.png" alt="See the changes" width="250px" />
</a>`
await github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
}
- name: Set up Deno
uses: denoland/setup-deno@v1
- name: Publish to JSR
run: |
deno run -A jsr:@david/[email protected] --allow-dirty
env:
GITHUB_REF: refs/tags/v${{ steps.set-version.outputs.version }}