-
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
20 changed files
with
665 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,56 @@ | ||
name: Publish Experimental Packages | ||
description: Bumps the version of an npm package and publishes it with an experimental tag. | ||
|
||
on: | ||
workflow_call: [] | ||
|
||
inputs: | ||
package_dir: | ||
description: Directory of the Package to Publish | ||
required: true | ||
default: './' | ||
|
||
outputs: | ||
VERSION_TAG: | ||
description: Generated Experimental Version Tag for This Package | ||
value: ${{ steps.version-tag.outputs.VERSION_TAG }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Construct Experimental Version Tag | ||
id: version-tag | ||
shell: bash | ||
run: | | ||
BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | sed -r 's/([a-z0-9])([A-Z])/\1-\L\2/g' | sed 's/_/-/g' | sed 's/\//-/g') | ||
echo "VERSION_TAG=$(echo $BRANCH_NAME)-experimental" >> $GITHUB_ENV | ||
echo "VERSION_TAG=$(echo $VERSION_TAG)" >> $GITHUB_OUTPUT | ||
- name: Bump ${{ inputs.package_dir }} | ||
shell: bash | ||
run: | | ||
cd ${{ inputs.package_dir }} | ||
PACKAGE_NAME=$(cat package.json | grep "name" | cut -d':' -f 2 | cut -d'"' -f 2) | ||
echo "PACKAGE_NAME=${PACKAGE_NAME}" >> $GITHUB_ENV | ||
# Matches any version that ends with "-author-ron-123-experimental.<number>". e.g. 1.0.0-leo-ron-123-experimental.0 | ||
REGEX="\-$VERSION_TAG.[0-9]\{1,\}$" | ||
# Get all versions | ||
ALL_VERSIONS=$(npm view $PACKAGE_NAME versions --json | jq -r '.[]') | ||
# Check if the experimental version already exists | ||
if ! echo "$ALL_VERSIONS" | grep -q "$REGEX"; then | ||
# If not, create it | ||
npm version prerelease --preid=$VERSION_TAG --no-git-tag-version | ||
else | ||
# Otherwise up it | ||
LATEST_VERSION=$(echo "$ALL_VERSIONS" | grep "$REGEX" | tail -1) | ||
npm version $(npx semver $LATEST_VERSION -i prerelease --preid="$VERSION_TAG") --no-git-tag-version | ||
fi | ||
- name: Publish to npm | ||
shell: bash | ||
run: cd ${{ inputs.package_dir }} && npm publish --tag="$VERSION_TAG" |
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,21 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: 'npm' | ||
directory: '/' | ||
|
||
# Open a new pull request every week, if there are updates available. | ||
schedule: | ||
interval: 'weekly' | ||
timezone: 'Europe/Berlin' | ||
|
||
labels: | ||
- 'enhancement' | ||
|
||
# Create one PR for all production dependencies, and one for all | ||
# development dependencies. The latter is easier/faster to merge because it | ||
# usually only affects local development. | ||
groups: | ||
production: | ||
dependency-type: 'production' | ||
development: | ||
dependency-type: 'development' |
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,51 @@ | ||
name: Publish Experimental Packages | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
name: Deploy | ||
permissions: | ||
# Required for `actions/checkout@v3` | ||
contents: read | ||
# Required for `thollander/actions-comment-pull-request@v2` | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Code Checkout | ||
uses: actions/[email protected] | ||
|
||
# Needed only for bumping package version and publishing npm packages. | ||
- name: Set up Node.js | ||
uses: actions/[email protected] | ||
- run: echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_READ_AND_WRITE }}' > ~/.npmrc | ||
|
||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v1 | ||
|
||
- name: Install Dependencies | ||
run: bun install --frozen-lockfile | ||
|
||
- name: Build Package | ||
run: bun run build | ||
|
||
- name: Bump `hono-ronin` | ||
id: bump-ronin | ||
uses: ./.github/actions/bump-version | ||
|
||
- name: Comment on PR | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
comment_tag: packages_announcement | ||
message: | | ||
Released an experimental package: | ||
```bash | ||
bun add hono-ronin@${{ env.VERSION_TAG }} | ||
``` | ||
This package will be removed after the pull request has been merged. |
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,71 @@ | ||
name: Manually Publish npm Packages | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version_type: | ||
description: Choose a version type to bump the package version by. | ||
required: true | ||
default: 'patch' | ||
type: choice | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
- prerelease | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
name: Deploy | ||
steps: | ||
- name: Generate GitHub App Token | ||
id: generate_token | ||
uses: tibdex/github-app-token@v1 | ||
with: | ||
app_id: ${{ secrets.ORG_GH_RONIN_APP_ID }} | ||
private_key: ${{ secrets.ORG_GH_RONIN_APP_PRIVATE_KEY }} | ||
|
||
- name: Code Checkout | ||
uses: actions/[email protected] | ||
with: | ||
token: ${{ steps.generate_token.outputs.token }} | ||
|
||
# Needed only for bumping package version and publishing npm packages. | ||
- name: Set up Node.js | ||
uses: actions/[email protected] | ||
- run: echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_READ_AND_WRITE }}' > ~/.npmrc | ||
|
||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v1 | ||
|
||
- name: Install Dependencies | ||
run: bun install --frozen-lockfile | ||
|
||
- name: Build Package | ||
run: bun run build | ||
|
||
- name: Set Git Config | ||
run: | | ||
# See where these config values come from at https://stackoverflow.com/a/74071223 | ||
git config --global user.name "ronin-app[bot]" | ||
git config --global user.email 135042755+ronin-app[bot]@users.noreply.github.com | ||
- name: Bump `hono-ronin` | ||
run: | | ||
npm version ${{ inputs.version_type }} --git-tag-version=false | ||
echo "NEW_VERSION=$(npm pkg get version --workspaces=false | tr -d \")" >> $GITHUB_ENV | ||
- name: Push New Version | ||
run: | | ||
git fetch | ||
git checkout ${GITHUB_HEAD_REF} | ||
git pull origin ${GITHUB_HEAD_REF} | ||
git commit -a -m '${{ env.NEW_VERSION }}' --no-verify | ||
git tag -a ${{ env.NEW_VERSION }} -m '${{ env.NEW_VERSION }}' | ||
git push origin ${GITHUB_HEAD_REF} | ||
# Push tag | ||
git push origin ${{ env.NEW_VERSION }} | ||
- name: Publish npm Package | ||
run: npm publish |
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 @@ | ||
name: Remove Experimental Packages | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: [closed] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
name: Remove Experimental Packages | ||
steps: | ||
- name: Code Checkout | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Node.js | ||
uses: actions/[email protected] | ||
- run: echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_READ_AND_WRITE }}' > ~/.npmrc | ||
|
||
# This converts the branch name into dash-case, so it can be used as a | ||
# valid dist-tag. | ||
- name: Extract Branch Name | ||
shell: bash | ||
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | sed -r 's/([a-z0-9])([A-Z])/\1-\L\2/g' | sed 's/_/-/g' | sed 's/\//-/g')" >> $GITHUB_ENV | ||
|
||
- name: Remove Experimental Packages | ||
run: npm dist-tag rm hono-ronin $BRANCH_NAME-experimental |
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,23 @@ | ||
name: Dependabot Auto-Merge | ||
on: pull_request | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
dependabot: | ||
runs-on: ubuntu-latest | ||
if: github.actor == 'dependabot[bot]' | ||
steps: | ||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/fetch-metadata@v1 | ||
with: | ||
github-token: '${{ github.token }}' | ||
|
||
- name: Enable auto-merge for Dependabot PRs | ||
run: gh pr merge --auto --squash "$PR_URL" | ||
env: | ||
PR_URL: ${{ github.event.pull_request.html_url }} | ||
GITHUB_TOKEN: ${{ github.token }} |
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,73 @@ | ||
name: Validate | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Code Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: 1.1.6 | ||
|
||
# Cache the local `node_modules` directory. | ||
- name: Restore npm cache | ||
id: cache-node-modules | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('patches/**') }}-${{ hashFiles('bun.lockb') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('patches/**') }}- | ||
${{ runner.os }}-build-${{ hashFiles('patches/**') }}- | ||
${{ runner.os }}-${{ hashFiles('patches/**') }}- | ||
- name: Install Dependencies | ||
if: steps.cache-node-modules.outputs.cache-hit != 'true' | ||
run: bun install --frozen-lockfile | ||
|
||
- name: Code Linting | ||
run: bun run lint | ||
|
||
test: | ||
name: Testing | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Code Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: 1.1.6 | ||
|
||
# Cache the local `node_modules` directory. | ||
- name: Restore npm cache | ||
id: cache-node-modules | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('patches/**') }}-${{ hashFiles('bun.lockb') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('patches/**') }}- | ||
${{ runner.os }}-build-${{ hashFiles('patches/**') }}- | ||
${{ runner.os }}-${{ hashFiles('patches/**') }}- | ||
- name: Install Dependencies | ||
if: steps.cache-node-modules.outputs.cache-hit != 'true' | ||
run: bun install --frozen-lockfile | ||
|
||
- name: Testing | ||
run: bun run test |
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,5 @@ | ||
# Build output | ||
dist | ||
|
||
# Dependencies | ||
node_modules |
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 @@ | ||
bunx lint-staged |
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,3 @@ | ||
{ | ||
"recommendations": ["biomejs.biome", "oven.bun-vscode", "redhat.vscode-yaml"] | ||
} |
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,12 @@ | ||
{ | ||
"editor.rulers": [80, 120], | ||
|
||
"editor.defaultFormatter": "biomejs.biome", | ||
"editor.formatOnSave": true, | ||
|
||
"javascript.updateImportsOnFileMove.enabled": "always", | ||
"javascript.preferences.importModuleSpecifier": "non-relative", | ||
|
||
"typescript.updateImportsOnFileMove.enabled": "always", | ||
"typescript.preferences.importModuleSpecifier": "non-relative" | ||
} |
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,21 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.7.1/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"indentStyle": "space", | ||
"indentWidth": 2 | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"correctness": { | ||
"noUnusedImports": "warn", | ||
"noUnusedVariables": "warn" | ||
} | ||
} | ||
} | ||
} |
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,7 @@ | ||
[install] | ||
exact = true | ||
|
||
[test] | ||
coverage = true | ||
coverageThreshold = 1.0 | ||
preload = ['./tests/preload.ts'] |
Oops, something went wrong.