diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2470499..075d995 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: jobs: check: - name: Check code + name: Check and Build code runs-on: ubuntu-latest steps: - name: Checkout @@ -24,18 +24,22 @@ jobs: run: bun run lint - name: Build all - run: bun run build - - - name: Build website env: + # For website BACKEND_URL: https://backend-modpackresolver.itrooz.fr - run: cd web && bun run build + run: bun run build - name: Upload website artifact uses: actions/upload-pages-artifact@v3 with: path: 'web/build/' + - name: Upload CLI artifact + uses: actions/upload-artifact@v4 + with: + name: modpackresolver-cli + path: 'cli/dist/*' + build-backend-image: name: Build backend image runs-on: ubuntu-latest diff --git a/.github/workflows/nightly_release.yml b/.github/workflows/nightly_release.yml new file mode 100644 index 0000000..cbee779 --- /dev/null +++ b/.github/workflows/nightly_release.yml @@ -0,0 +1,56 @@ +# Inspired from https://github.com/WerWolv/ImHex/blob/16dc199431858de984fb0ed3b50d60a9a9e511b1/.github/workflows/nightly_release.yml + +name: Nightly Release + +on: + push: + branches: + - main + workflow_dispatch: + +env: + NIGHTLY_TAG: nightly + +jobs: + nightly-release: + runs-on: ubuntu-24.04 + name: 🌃 Update Nightly Release + permissions: + contents: write + + steps: + - name: 🧰 Checkout + uses: actions/checkout@v4 + with: + path: project + fetch-depth: 0 + fetch-tags: true + + - name: ⬇️ Download artifacts from latest workflow + uses: dawidd6/action-download-artifact@v6 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + workflow: ci.yml + branch: ${{ github.event.release.target_commitish }} + workflow_conclusion: success + + - name: 📦 Update Pre-Release + run: | + set -e + + cd project + + # Move nightly tag to latest commit + git tag -f $NIGHTLY_TAG HEAD + git push origin $NIGHTLY_TAG --force + + # Auth for GitHub CLI + echo "${{ github.token }}" | gh auth login --with-token + + # Delete existing assets + for asset in $(gh release view $NIGHTLY_TAG --json assets --jq '.assets[].name'); do + gh release delete-asset $NIGHTLY_TAG "$asset" --yes + done + + # Upload new assets + gh release upload $NIGHTLY_TAG ../*.* --clobber diff --git a/cli/package.json b/cli/package.json index ba0240a..5e589aa 100644 --- a/cli/package.json +++ b/cli/package.json @@ -11,7 +11,7 @@ "pino-pretty": "^13.0.0" }, "scripts": { - "build": "(cd ../mclib && bun run build) && bun build src/index.ts --outdir dist --minify --target node", + "build": "(cd ../mclib && bun run build) && bun build src/index.ts --outfile dist/modpackresolver-cli --compile", "start": "(cd ../mclib && bun run build) && bun src/index.ts", "lint": "eslint .", "opt:proxy": "HTTP_PROXY=http://127.0.0.1:8080 HTTPS_PROXY=http://127.0.0.1:8080" diff --git a/cli/src/index.ts b/cli/src/index.ts index a187461..e4bcb4d 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -4,6 +4,7 @@ import { program, Option } from '@commander-js/extra-typings'; import { CurseForgeRepository, LocalSolutionFinder, LoggerConfig, ModLoader, ModrinthRepository, LogLevel, Constraints, Solution, ModMetadata, RepositoryUtil, ModRepositoryName, RemoteModQueryService, IModQueryService, IRepository, LocalModQueryService } from 'mclib'; import { readFileSync } from 'fs'; import pino from 'pino'; +import pinoPretty from 'pino-pretty'; // Logging setup const LOG_LEVEL = (process.env.LOG_LEVEL ?? "info") as LogLevel; @@ -11,14 +12,8 @@ const logger = pino({ level: LOG_LEVEL, base: { pid: false, - }, - transport: { - target: 'pino-pretty', - options: { - colorize: true - } } -}); +}, pinoPretty()); LoggerConfig.setLevel(LOG_LEVEL); // Fetch wrapper to log timing and errors @@ -268,4 +263,11 @@ program } }); + +// Workaround. See https://github.com/oven-sh/bun/issues/22283 +if (process.argv.length >= 3) { + if (process.argv[2].endsWith('modpackresolver-cli')) { + process.argv.splice(2, 1); // remove argv[2] + } +} program.parse(process.argv); diff --git a/mclib/src/logger.ts b/mclib/src/logger.ts index 87c01a6..36023d4 100644 --- a/mclib/src/logger.ts +++ b/mclib/src/logger.ts @@ -1,4 +1,5 @@ import pino from 'pino'; +import pinoPretty from 'pino-pretty'; export enum LogLevel { Fatal = 'fatal', @@ -13,14 +14,8 @@ const logger = pino({ level: 'info', // default level base: { pid: false, - }, - transport: { - target: 'pino-pretty', - options: { - colorize: true - } } -}); +}, pinoPretty()); class LoggerConfig { static setLevel(level: LogLevel): void {