-
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
14 changed files
with
1,238 additions
and
1 deletion.
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,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@v2 | ||
with: | ||
platforms: ${{ matrix.target.emulate }} | ||
|
||
- name: Check out | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: develop | ||
|
||
- 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,41 @@ | ||
name: Docker | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish-dockerhub: | ||
if: ${{ secrets.DOCKER_REPO }} | ||
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: ${{ secrets.DOCKER_REPO }} | ||
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 | ||
- 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,8 @@ | ||
cd dist | ||
|
||
cat package.json | jq ".version=\"0.0.0-$GITHUB_SHA\" | .private=false" > package.json.tmp | ||
mv -f package.json.tmp package.json | ||
|
||
cd .. | ||
tar -czf dist.tgz dist | ||
npm publish dist.tgz --access public --tag latest |
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 @@ | ||
mkdir -p $RUNNER_TEMP/dist | ||
cp -a * $RUNNER_TEMP/dist | ||
cp -a .github $RUNNER_TEMP/dist | ||
cp -a .vscode $RUNNER_TEMP/dist | ||
cp -a .yarn $RUNNER_TEMP/dist | ||
cp .* $RUNNER_TEMP/dist | ||
mv $RUNNER_TEMP/dist dist | ||
|
||
cd dist | ||
|
||
# modify package.json | ||
cat package.json | jq '.version="0.0.0" | del(.optionalDependencies)' > package.json.tmp | ||
mv -f package.json.tmp package.json | ||
|
||
sed -i .gitignore \ | ||
-e '/yarn.lock/d' | ||
|
||
# modify workflows | ||
cd .github/workflows | ||
rm publish.sh | ||
rm sync.sh | ||
rm sync.yml | ||
|
||
sed -i tag.yml \ | ||
-e 's/develop/master/g' | ||
|
||
sed -i build.yml \ | ||
-e 's/develop/master/g' |
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,41 @@ | ||
name: Sync | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
sync: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- name: Sync files | ||
run: bash .github/workflows/sync.sh | ||
|
||
- name: Deploy master | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.WORKFLOW_TOKEN }} | ||
publish_dir: dist | ||
publish_branch: master | ||
# https://github.com/peaceiris/actions-gh-pages/issues/163 | ||
exclude_assets: '' | ||
force_orphan: true | ||
enable_jekyll: true | ||
commit_message: '[skip ci] deploy' | ||
|
||
- name: Publish | ||
run: bash .github/workflows/publish.sh | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GITHUB_SHA: ${{ 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,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: | ||
- develop | ||
|
||
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 |
Oops, something went wrong.