Skip to content

Publish

Publish #95

Workflow file for this run

name: Publish
on:
workflow_dispatch:
push:
branches:
- '!*'
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Bun
uses: oven-sh/setup-bun@v1
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Build
run: bun run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: dist
- name: Release
id: release
if: github.event_name != 'workflow_dispatch'
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ github.token }}
prerelease: false
files: |
dist/script.meta.js
dist/script.user.js
- name: Update release body
if: steps.release.outcome == 'success'
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.release.outputs.automatic_releases_tag }}"
EXISTING="$(gh release view "$TAG" --json body -q .body)"
APPEND="$(cat <<'EOF'
## Installation
[Via Greasy Fork](https://greasyfork.org/scripts/375992) (login required due to adult content)
[Via Sleazy Fork](https://sleazyfork.org/scripts/375992) (no login required)
[Via GitHub Release](https://github.com/Tsuk1ko/nhentai-helper/releases/latest/download/script.user.js)
[Via GitHub Pages](https://nhelper.lolicon.app/script.user.js)
EOF
)"
gh release edit "$TAG" --notes "$(printf '%s\n\n%s\n' "$EXISTING" "$APPEND")"
- name: Prepare dist branch files
run: |
cp .gitignore ./dist
rm ./dist/*.html
- name: Trigger Greasy Fork synchronization
uses: casperdcl/push-dir@v1
with:
message: ${{ github.ref_name }}
branch: dist
dir: dist
history: true
nojekyll: true
deploy:
needs: build
runs-on: ubuntu-latest
concurrency:
group: 'pages'
cancel-in-progress: true
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4