feat(npm): Build and publish NPM package (#43)

This commit is contained in:
Steven Noorbergen
2024-05-05 16:35:22 +02:00
committed by GitHub
parent cfe3da0aed
commit abc6b132a8
10 changed files with 207 additions and 3 deletions

View File

@@ -14,11 +14,27 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Install NodeJS
uses: actions/setup-node@v4
with:
registry-url: https://npm.pkg.github.com
scope: "@eveshipfit"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set version
run: |
# Remove the "v" from the version.
VERSION=$(echo ${{ github.ref_name }} | cut -b2-)
echo "Version: ${VERSION}"
sed -i 's/"version": "0.0.0-git"/"version": "'${VERSION}'"/' package.json
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends rclone protobuf-compiler
pip install -r requirements.txt
npm install
- name: Setup rclone
run: |
@@ -63,9 +79,20 @@ jobs:
run: |
python download_icons.py sde/fsd
- name: Build package
run: |
npm run build
- name: Publish package
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
registry: "https://npm.pkg.github.com"
package: package.json
- name: Publish to R2 bucket
run: |
rclone copy dist eveshipfit:eveshipfit/${{ github.event.release.tag_name }}/ --progress
rclone copy dist eveshipfit:eveshipfit/${{ github.event.release.tag_name }}/ --progress --exclude=*.{js,js.map,d.ts}
env:
RCLONE_CONFIG_EVESHIPFIT_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_EVESHIPFIT_ENDPOINT: ${{ secrets.R2_ENDPOINT }}

32
.github/workflows/testing.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: Testing
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
testing:
name: Testing
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install NodeJS
uses: actions/setup-node@v4
with:
registry-url: https://npm.pkg.github.com
scope: "@eveshipfit"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: npm install
- name: Run linter
run: npm run lint