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

Initial setup #1

Merged
merged 11 commits into from
Aug 20, 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
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root=true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{mjs,cjs,js,mts,cts,ts,json,vue,html,scss,css,toml,md}]
indent_style = tab

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_style = space
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** -diff linguist-generated=true
34 changes: 34 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Setup
description: Configure Node.js + pnpm and install dependencies

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: package.json

- uses: pnpm/action-setup@v4
name: Setup pnpm
id: pnpm-install
with:
run_install: false

- name: Get pnpm cache dir
id: pnpm-cache-dir
shell: bash
run: echo "pnpm-cache-dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache-dir.outputs.pnpm-cache-dir }}
key:
${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
shell: bash
run: pnpm install
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build

on:
push:
branches:
- main

permissions:
contents: write

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Build
run: pnpm run build

- name: Commit changes
run: |
author='${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>'
message='Update build artifacts [skip ci]'
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit --all --author "$author" --message "$message" || true
git push
81 changes: 81 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Check

on:
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Run linter
run: pnpm run lint

typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Run typecheck
run: pnpm run typecheck

test-unit:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Run tests
run: pnpm test

test-action:
name: Action Test
runs-on: ubuntu-latest
permissions:
issues: read
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Build
run: pnpm run build

- name: Run action
id: action
uses: ./
with:
stale-label: stale
days-before-close: 7
close-message: Closing this issue as it has become stale.
dry-run: true

- name: Check output
run: |
echo 'closed-issues=${{ steps.action.outputs.closed-issues }}'
${{ startsWith(steps.action.outputs.closed-issues, '[') }} || { echo '::error::Expected "closed-issues" output to start with ['; exit 1; }
${{ endsWith(steps.action.outputs.closed-issues, ']') }} || { echo '::error::Expected "closed-issues" output to end with ]'; exit 1; }
91 changes: 91 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: SemVer for the release, for example "1.0.0"
required: true
type: string

permissions:
contents: write

jobs:
check-version:
name: Check Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.release }}
major-version: ${{ steps.version.outputs.major }}
is-prerelease: ${{ steps.version.outputs.prerelease && true || false }}
steps:
- name: Check version
uses: madhead/semver-utils@v4
id: version
with:
version: ${{ inputs.version }}
lenient: false

create-version:
name: Create Version
runs-on: ubuntu-latest
needs: check-version
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Build
run: pnpm run build

- name: Update version in readme
run: |
version='${{ needs.check-version.outputs.major-version }}'
sed \
-i 's/\(<!-- version:start -->\).*\(<!-- version:end -->\)/\1'"$version"'\2/g' \
readme.md
- name: Create version commit & tags
run: |
author='${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>'
version='v${{ needs.check-version.outputs.version }}'
majorVersion='v${{ needs.check-version.outputs.major-version }}'
branch='${{ github.ref }}'
isPrerelease='${{ needs.check-version.outputs.is-prerelease }}'
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit --all --author "$author" --message "$version" || true
git tag --annotate "$version" --message "$version"
git push --atomic origin "$branch" "$version"
if [ "$isPrerelease" = false ]; then
git tag --force --annotate "$majorVersion" --message "$majorVersion"
git push --force origin "$majorVersion"
fi
create-release:
name: Create Release
runs-on: ubuntu-latest
needs:
- check-version
- create-version
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create \
'v${{ needs.check-version.outputs.version }}' \
--verify-tag \
--generate-notes \
${{ needs.check-version.outputs.is-prerelease == 'true' && '--prerelease' || '' }}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# User preferences
.DS_Store

# Dependencies
node_modules/

# Builds / Caches
coverage/
*.tsbuildinfo
.eslintcache

# IDEs / Editors
.idea/
*.code-workspace
.history/
*.sublime-settings
.*.swp
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
engine-strict=true
shell-emulator=true
save-prefix=''
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "editorconfig.editorconfig"]
}
49 changes: 49 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off", "fixable": true },
{ "rule": "format/*", "severity": "off", "fixable": true },
{ "rule": "*-indent", "severity": "off", "fixable": true },
{ "rule": "*-spacing", "severity": "off", "fixable": true },
{ "rule": "*-spaces", "severity": "off", "fixable": true },
{ "rule": "*-order", "severity": "off", "fixable": true },
{ "rule": "*-dangle", "severity": "off", "fixable": true },
{ "rule": "*-newline", "severity": "off", "fixable": true },
{ "rule": "*quotes", "severity": "off", "fixable": true },
{ "rule": "*semi", "severity": "off", "fixable": true }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"css",
"less",
"scss",
"pcss",
"postcss"
]
}
37 changes: 37 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Close Stale Issues
description: Close issues certain days after a stale label has been added
author: Directus

branding:
icon: calendar
color: red

inputs:
github-token:
required: true
description: GitHub token with read access and issue update access to github-repo
default: ${{ github.token }}
github-repo:
required: true
description: GitHub `owner/repository` for which stale issues are paused
default: ${{ github.repository }}
stale-label:
required: true
description: Label which marks an issue as stale
days-before-close:
required: true
description: Days before an issue is closed after the stale label has been added to it
close-comment:
required: true
description: Comment which will be added to issues when closing
dry-run:
description: Run the action without effectively closing stale issues
paescuj marked this conversation as resolved.
Show resolved Hide resolved
default: 'false'

outputs:
closed-issues:
description: List with numbers of all issues that have been closed

runs:
using: node20
main: dist/index.js
Loading
Loading