Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Commit

Permalink
ci: fix ncc packaging (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 authored Jan 27, 2023
1 parent 41ea6ba commit 7e9ff33
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
need-merge: ${{ steps.platform-matrix.outputs.need-merge }}
# ビルド対象情報のマトリクス
targets-matrix: ${{ steps.targets-matrix.outputs.matrix }}
# パッケージのアップロードが必要かどうか
need-upload: ${{ steps.need-upload.outputs.need-upload }}

steps:
- name: Check out the repo
Expand Down Expand Up @@ -93,6 +95,17 @@ jobs:
env:
TARGETS: ${{ env.TARGETS }}

- name: Check if need package upload
id: need-upload
run: |
# package.json がない場合は false
if [ ! -f package.json ]; then
echo "need-upload=false" >> $GITHUB_OUTPUT
exit 0
fi
# "ncc build" が package.json にある場合は true、ない場合は false
echo "need-upload=$(grep -q 'ncc build' package.json && echo true || echo false)" >> $GITHUB_OUTPUT
# Dockerイメージをビルドする
build:
name: Docker build (${{ matrix.target.packageName }}, ${{ matrix.platform }})
Expand Down Expand Up @@ -291,7 +304,7 @@ jobs:
upload-package:
name: Upload package ${{ needs.calc-version.outputs.tag }}
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
if: ${{ github.event.pull_request.merged == true && needs.calc-version.outputs.need-upload == 'true' }}
needs:
- calc-version
- build
Expand All @@ -316,10 +329,19 @@ jobs:
- name: 🎁 Run package
run: yarn package

- name: Create zip
id: create-zip
working-directory: output
run: |
REPO="${GITHUB_REPOSITORY#"${GITHUB_REPOSITORY_OWNER}/"}"
zip -r "${REPO}_${{ needs.calc-version.outputs.tag }}.zip" ./*
echo "zip-path=output/${REPO}-${{ needs.calc-version.outputs.tag }}.zip" >> $GITHUB_OUTPUT
echo "zip-filename=${REPO}-${{ needs.calc-version.outputs.tag }}.zip" >> $GITHUB_OUTPUT
- name: Upload Release Asset
uses: shogo82148/[email protected]
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: output/index.js
asset_name: index.js
asset_content_type: text/javascript
asset_path: ${{ steps.create-zip.outputs.zip-path }}
asset_name: ${{ steps.create-zip.outputs.zip-filename }}
asset_content_type: application/zip
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ After that, you can start it with `docker-compose up -d` after creating a config

If you are running in a Node.js environment, Node.js v18 is recommended.

Download `index.js` from the [release page](https://github.com/tomacheese/twitter-dm-memo/releases) in the latest release.
Download and extract `twitter-dm-memo_vX.Y.Z.zip` from the [release page](https://github.com/tomacheese/twitter-dm-memo/releases) in the latest release.
After that, you can start it with `node index.js` after creating a configuration file with reference to [Configuration section](#configuration).

## Configuration
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start": "ts-node -r tsconfig-paths/register ./src/main.ts",
"dev": "ts-node-dev -r tsconfig-paths/register ./src/main.ts",
"package": "run-s clean compile packing",
"packing": "ncc build ./dist/main.js -o output/ -m -s",
"packing": "ncc build ./dist/main.js -o output/ -m",
"compile": "tsc -p .",
"compile:test": "tsc -p . --noEmit",
"clean": "rimraf dist output",
Expand Down

0 comments on commit 7e9ff33

Please sign in to comment.