Skip to content

Commit

Permalink
sync with cordis boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed May 14, 2024
1 parent 1bb61dc commit d481e88
Show file tree
Hide file tree
Showing 14 changed files with 392 additions and 449 deletions.
25 changes: 6 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: build

on:
release:
Expand All @@ -8,6 +8,9 @@ on:

jobs:
build:
permissions:
contents: write

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -44,8 +47,6 @@ jobs:

- name: Check out
uses: actions/checkout@v4
with:
ref: develop

- name: Set up Node
if: ${{ !matrix.target.emulate }}
Expand All @@ -66,8 +67,7 @@ jobs:
run: bash .github/workflows/prepare.sh

- name: Install dependencies
run: |
yarn --no-immutable
run: yarn --no-immutable

- name: Pack file
run: bash .github/workflows/pack.sh
Expand All @@ -78,17 +78,4 @@ jobs:
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
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion .github/workflows/clean.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Clean
name: clean

on:
release:
Expand All @@ -7,6 +7,9 @@ on:

jobs:
clean:
permissions:
contents: write

runs-on: ubuntu-latest

steps:
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/docker.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
mkdir -p $RUNNER_TEMP/dist
cp -a * $RUNNER_TEMP/dist
cp -a .github $RUNNER_TEMP/dist
cp -a .vscode $RUNNER_TEMP/dist
cp .* $RUNNER_TEMP/dist

cd .yarn
mkdir $RUNNER_TEMP/dist/.yarn
cp -a patches $RUNNER_TEMP/dist/.yarn
cp -a plugins $RUNNER_TEMP/dist/.yarn
cp -a releases $RUNNER_TEMP/dist/.yarn
cp -a sdks $RUNNER_TEMP/dist/.yarn
cp -a versions $RUNNER_TEMP/dist/.yarn

mv $RUNNER_TEMP/dist dist
cd dist

rm -rf node_modules

# do not ignore lockfiles
sed -i .gitignore \
-e '/yarn.lock/d'

# if $GITHUB_REF is in the form of refs/tags/v* then it's a release
if [[ $GITHUB_REF == refs/tags/v* ]]; then
cat package.json | jq ".private=false" > package.json.tmp
mv -f package.json.tmp package.json
cd ..
tar -czf dist.tgz dist
npm publish dist.tgz --access public
else
VERSION=$(cat package.json | grep '"version":' | cut -d '"' -f 4)
cat package.json | jq ".version=\"$VERSION-$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 nightly
fi
36 changes: 36 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: npm

on:
push:
branches:
- main
tags:
- v*
release:
types:
- created
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Check out
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/

- name: Install dependencies
run: yarn --no-immutable

- name: Publish
if: ${{ env.NODE_AUTH_TOKEN }}
run: bash .github/workflows/npm.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_REF: ${{ github.ref }}
GITHUB_SHA: ${{ github.sha }}
2 changes: 0 additions & 2 deletions .github/workflows/prepare.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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,
Expand All @@ -10,6 +9,5 @@ source.scripts = {
delete source.yakumo
delete source.workspaces
delete source.devDependencies
delete source.optionalDependencies

writeFileSync('package.json', JSON.stringify(source, null, 2))
8 changes: 0 additions & 8 deletions .github/workflows/publish.sh

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/sync.sh

This file was deleted.

41 changes: 0 additions & 41 deletions .github/workflows/sync.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/workflows/tag.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
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
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
name: Tag
name: tag

on:
push:
branches:
- develop
- main

jobs:
release:
permissions:
contents: write

runs-on: ubuntu-latest

steps:
Expand All @@ -25,7 +28,7 @@ jobs:
curl
-X POST
-H "Accept: application/vnd.github.v3+json"
-H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}"
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
https://api.github.com/repos/${{ github.repository }}/releases
-d '{
"name": "${{ steps.version.outputs.tag }}",
Expand Down
Loading

0 comments on commit d481e88

Please sign in to comment.