Files
naxos-api/.gitea/workflows/ci.yaml
T
Lukas Holzner 784a9b742d
CI & Test NaxOS Management API / test (push) Successful in 14m53s
feat(ci): publish standalone runtime tarball with production node_modules
2026-09-04 09:54:17 +02:00

72 lines
2.4 KiB
YAML

name: CI & Test NaxOS Management API
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: write
packages: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install Dependencies
run: npm ci || npm install
- name: Typecheck
run: npx tsc --noEmit
- name: Run Unit Tests
run: npm test
- name: Build Management Daemon
run: npm run build
- name: Publish Package to Gitea Packages
run: |
npm pack
TGZ_FILE=$(ls naxos-api-*.tgz | head -n 1)
echo "Packaging $TGZ_FILE to Gitea Packages registry..."
TOKEN="${{ secrets.PACKAGE_TOKEN }}"
if [ -z "$TOKEN" ]; then
TOKEN="${{ secrets.GITEA_TOKEN }}"
fi
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -X PUT \
-H "Authorization: token ${TOKEN}" \
--upload-file "$TGZ_FILE" \
"${{ github.server_url }}/api/packages/naxos/generic/naxos-api/1.0.0/$TGZ_FILE")
STATUS=$(echo "$RESPONSE" | grep "HTTP_STATUS:" | cut -d: -f2)
BODY=$(echo "$RESPONSE" | grep -v "HTTP_STATUS:")
echo "Package upload HTTP status: $STATUS"
if [ "$STATUS" -eq 201 ] || [ "$STATUS" -eq 200 ] || [ "$STATUS" -eq 204 ]; then
echo "Successfully published $TGZ_FILE to Gitea Packages!"
elif [ "$STATUS" -eq 409 ]; then
echo "Package version 1.0.0 already published in Gitea Packages: $BODY"
else
echo "Failed to publish package to Gitea Packages ($STATUS): $BODY"
exit 1
fi
echo "//git.lholz.de/api/packages/naxos/npm/:_authToken=${TOKEN}" >> ~/.npmrc
npm publish || echo "NPM package published or exists in registry"
# Publish pre-bundled standalone runtime with production node_modules
npm prune --omit=dev
tar -czf naxos-api-runtime.tar.gz dist node_modules package.json
curl -s -X PUT \
-H "Authorization: token ${TOKEN}" \
--upload-file naxos-api-runtime.tar.gz \
"${{ github.server_url }}/api/packages/naxos/generic/naxos-api/1.0.0/naxos-api-runtime.tar.gz" || echo "Runtime package already exists"