-
Notifications
You must be signed in to change notification settings - Fork 10
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
0 parents
commit 7ed8861
Showing
27 changed files
with
1,552 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,9 @@ | ||
root = true | ||
|
||
[*] | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = 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,3 @@ | ||
GITHUB_MIRROR = https://ghproxy.com/https://github.com | ||
GITHUB_CONTENT_MIRROR = https://ghproxy.com/https://raw.githubusercontent.com | ||
GRAVATAR_MIRROR = https://cravatar.cn |
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,9 @@ | ||
* text eol=lf | ||
|
||
*.png -text | ||
*.jpg -text | ||
*.ico -text | ||
*.gif -text | ||
*.webp -text | ||
|
||
yarn-*.cjs linguist-vendored |
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,94 @@ | ||
name: Build | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- runs-on: windows-latest | ||
platform: windows | ||
- runs-on: ubuntu-latest | ||
platform: linux | ||
- runs-on: ubuntu-latest | ||
platform: linux | ||
emulate: arm64 | ||
- runs-on: macos-latest | ||
platform: darwin | ||
|
||
runs-on: ${{ matrix.target.runs-on }} | ||
|
||
steps: | ||
- name: Set up variables | ||
id: vars | ||
shell: bash | ||
run: | | ||
echo "NODE_VERSION=${{ matrix.target.node || '20' }}" >> $GITHUB_OUTPUT | ||
echo "ARCH=${{ matrix.target.emulate || 'amd64' }}" >> $GITHUB_OUTPUT | ||
- name: Install nix (for arm64) | ||
if: ${{ matrix.target.emulate }} | ||
uses: cachix/install-nix-action@v20 | ||
|
||
- name: Set up qemu and binfmt (for arm64) | ||
if: ${{ matrix.target.emulate }} | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: ${{ matrix.target.emulate }} | ||
|
||
- name: Check out | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: master | ||
|
||
- name: Set up Node | ||
if: ${{ !matrix.target.emulate }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ steps.vars.outputs.NODE_VERSION }} | ||
|
||
- name: Set up Node (for arm64) | ||
if: ${{ matrix.target.emulate == 'arm64' }} | ||
run: | | ||
nix profile install github:NixOS/nixpkgs/04719f0326c5f8084f1fc7d1ca3fb15f8f09bb5e#nodejs_${{ steps.vars.outputs.NODE_VERSION }} --option system aarch64-linux | ||
- name: Install zip (for windows) | ||
if: ${{ matrix.target.platform == 'windows' }} | ||
run: choco install zip | ||
|
||
- name: Prepare | ||
run: bash .github/workflows/prepare.sh | ||
|
||
- name: Install dependencies | ||
run: | | ||
yarn --no-immutable | ||
- name: Pack file | ||
run: bash .github/workflows/pack.sh | ||
|
||
- name: Upload asset | ||
shell: bash | ||
run: > | ||
bash .github/workflows/upload.sh | ||
'${{ matrix.target.platform }}-${{ steps.vars.outputs.ARCH }}-node${{ steps.vars.outputs.NODE_VERSION }}' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} | ||
|
||
docker: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
- name: Trigger docker build | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} | ||
if: ${{ env.DOCKER_USERNAME != null }} | ||
run: gh workflow run Docker |
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 @@ | ||
name: Clean | ||
|
||
on: | ||
release: | ||
types: | ||
- deleted | ||
|
||
jobs: | ||
clean: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Delete tag | ||
run: | | ||
git tag -d ${{ github.event.release.tag_name }} | ||
git push origin :refs/tags/${{ github.event.release.tag_name }} |
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,48 @@ | ||
name: Docker | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish-dockerhub: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Docker Hub login | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
echo "${DOCKER_PASSWORD}" | docker login \ | ||
--username "${DOCKER_USERNAME}" \ | ||
--password-stdin | ||
- name: Run buildx and push | ||
env: | ||
DOCKER_REPO: koishijs/koishi | ||
GITHUB_REPO: ${{ github.repository }} | ||
run: | | ||
TAG=$(curl "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" | jq -r '.tag_name') | ||
NAME=$(cat package.json | jq -r '.name' | sed -E 's/.+\///') | ||
LINK="https://github.com/${GITHUB_REPO}/releases/download/$TAG/$NAME-$TAG-linux-" | ||
docker buildx build \ | ||
--build-arg LINK=$LINK \ | ||
--output "type=image,push=true" \ | ||
--platform linux/amd64,linux/arm64 \ | ||
--tag ${DOCKER_REPO}:$TAG \ | ||
--tag ${DOCKER_REPO}:latest \ | ||
--file ./docker/Dockerfile \ | ||
./docker | ||
docker buildx build \ | ||
--build-arg LINK=$LINK \ | ||
--output "type=image,push=true" \ | ||
--platform linux/amd64,linux/arm64 \ | ||
--tag ${DOCKER_REPO}:$TAG-lite \ | ||
--tag ${DOCKER_REPO}:latest-lite \ | ||
--file ./docker/Dockerfile.lite \ | ||
./docker | ||
- name: Docker Hub logout | ||
if: always() | ||
run: docker logout |
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,29 @@ | ||
rm .gitignore | ||
|
||
echo "package.json" >> .gitignore | ||
echo "README*" >> .gitignore | ||
echo "LICENSE*" >> .gitignore | ||
echo "yarn.lock" >> .gitignore | ||
echo "node_modules" >> .gitignore | ||
echo ".yarnrc.yml" >> .gitignore | ||
echo "!.git" >> .gitignore | ||
echo "!.yarn" >> .gitignore | ||
echo ".yarn/patches" >> .gitignore | ||
echo ".yarn/plugins" >> .gitignore | ||
echo ".yarn/releases" >> .gitignore | ||
echo ".yarn/sdks" >> .gitignore | ||
echo ".yarn/versions" >> .gitignore | ||
|
||
for file in $(cat package.json | jq -r '.files' | sed '1d' | sed '$d'); do | ||
echo $file | cut -d \" -f 2 >> .gitignore | ||
done | ||
|
||
for file in $(find . -type f,l | git check-ignore --stdin --no-index); do | ||
dir=$(dirname $RUNNER_TEMP/bundle/$file) | ||
mkdir -p $dir | ||
cp -a $file $dir | ||
done | ||
|
||
cd $RUNNER_TEMP/bundle | ||
|
||
zip $([[ $OSTYPE = "msys" ]] && echo "-9qr" || echo "-9qry") ../bundle.zip $(ls -A) |
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,15 @@ | ||
const { readFileSync, writeFileSync } = require('fs') | ||
|
||
const source = JSON.parse(readFileSync('package.json', 'utf8')) | ||
Object.assign(source.dependencies, source.optionalDependencies) | ||
|
||
source.scripts = { | ||
start: source.scripts.start, | ||
} | ||
|
||
delete source.yakumo | ||
delete source.workspaces | ||
delete source.devDependencies | ||
delete source.optionalDependencies | ||
|
||
writeFileSync('package.json', JSON.stringify(source, null, 2)) |
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,8 @@ | ||
# remove ^ from package.json | ||
# do not use sed -i, it behaves differently on Linux and MacOS | ||
cat package.json | sed 's/\^//g' > package.json.tmp | ||
mv -f package.json.tmp package.json | ||
|
||
# remove development-related fields | ||
# merge optionalDependencies into dependencies | ||
node .github/workflows/prepare.cjs |
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 @@ | ||
TAG=v$(cat package.json | grep '"version":' | cut -d '"' -f 4) | ||
|
||
if [ $TAG == 'v0.0.0' ]; then | ||
exit 0 | ||
fi | ||
|
||
REG=^$(echo $TAG | sed 's/\./\\./g')$ | ||
|
||
if [ -z "$(git tag -l | grep $REG)" ]; then | ||
echo new version detected: $TAG | ||
echo "tag=$TAG" >> $GITHUB_OUTPUT | ||
fi |
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,34 @@ | ||
name: Tag | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- id: version | ||
name: Check version | ||
run: bash .github/workflows/tag.sh | ||
|
||
- name: Create release | ||
if: ${{ steps.version.outputs.tag }} | ||
run: > | ||
curl | ||
-X POST | ||
-H "Accept: application/vnd.github.v3+json" | ||
-H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" | ||
https://api.github.com/repos/${{ github.repository }}/releases | ||
-d '{ | ||
"name": "${{ steps.version.outputs.tag }}", | ||
"tag_name": "${{ steps.version.outputs.tag }}", | ||
"target_commitish": "${{ github.sha }}" | ||
}' |
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,13 @@ | ||
variant=$1 | ||
|
||
name=$(cat package.json | jq -r '.name' | cut -d / -f 2) | ||
tag_name=$(gh release view --json name --jq .name) | ||
upload_file=$RUNNER_TEMP/$name-$tag_name-$variant.zip | ||
|
||
echo name: $name | ||
echo tag_name: $tag_name | ||
echo upload_file: $upload_file | ||
|
||
mv $RUNNER_TEMP/bundle.zip $upload_file | ||
|
||
gh release upload $tag_name $upload_file |
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,31 @@ | ||
lib | ||
dist | ||
/cache | ||
/data | ||
/temp | ||
external | ||
|
||
.env.local | ||
|
||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
package-lock.json | ||
pnpm-lock.yaml | ||
node_modules | ||
npm-debug.log | ||
yarn-debug.log | ||
yarn-error.log | ||
tsconfig.tsbuildinfo | ||
|
||
.eslintcache | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln |
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 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Koishi", | ||
"type": "node-terminal", | ||
"request": "launch", | ||
"cwd": "${workspaceFolder}", | ||
"command": "npm run dev" | ||
} | ||
] | ||
} |
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,8 @@ | ||
{ | ||
"git.repositoryScanIgnoredFolders": [ | ||
"node_modules", | ||
".yarn", | ||
], | ||
"git.repositoryScanMaxDepth": 10, | ||
"git.autoRepositoryDetection": "subFolders", | ||
} |
Oops, something went wrong.