feat: clean up apps and add publish
All checks were successful
Release / build_test (pull_request) Successful in 51s
All checks were successful
Release / build_test (pull_request) Successful in 51s
This commit is contained in:
134
.gitea/workflows/publish.yml
Normal file
134
.gitea/workflows/publish.yml
Normal file
@@ -0,0 +1,134 @@
|
||||
name: Publish
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: false
|
||||
group: publish-${{ github.ref_name }}
|
||||
|
||||
env:
|
||||
ACT_OWNER: ${{ github.repository_owner }}
|
||||
ACT_REPOSITORY: ${{ github.repository }}
|
||||
CGO_ENABLED: 0
|
||||
# Default comma-separated list of projects to build+publish. Can be overridden
|
||||
# when manually dispatching the workflow via the `projects` input.
|
||||
PUBLISH_PROJECTS: 'reviews-stars'
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
projects:
|
||||
description: 'Comma-separated list of Nx projects to build and publish'
|
||||
required: false
|
||||
default: 'reviews-stars'
|
||||
version:
|
||||
description: 'Semantic version to publish (e.g. 1.2.3). If omitted for tag runs, the tag name is used.'
|
||||
required: false
|
||||
npm_tag:
|
||||
description: 'NPM dist-tag to use (overrides automatic selection). default: auto (latest for release, next for prerelease)'
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
projects: ${{ steps.set-projects.outputs.projects }}
|
||||
env:
|
||||
PUBLISH_PROJECTS: ${{ github.event.inputs.projects || env.PUBLISH_PROJECTS }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: git fetch --force --tags
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Install dependencies
|
||||
run: npm ci --legacy-peer-deps
|
||||
- name: Build projects
|
||||
run: |
|
||||
echo "Projects to build: $PUBLISH_PROJECTS"
|
||||
npx nx run-many --target=build --projects="$PUBLISH_PROJECTS"
|
||||
- name: Upload dist artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: dist
|
||||
path: dist
|
||||
- name: Set projects output (JSON array)
|
||||
id: set-projects
|
||||
run: |
|
||||
# Convert comma-separated list into JSON array
|
||||
IFS=',' read -ra PROJS <<< "$PUBLISH_PROJECTS"
|
||||
json='['
|
||||
first=true
|
||||
for p in "${PROJS[@]}"; do
|
||||
p_trimmed=$(echo "$p" | xargs)
|
||||
if [ "$first" = true ]; then
|
||||
json+="\"$p_trimmed\""
|
||||
first=false
|
||||
else
|
||||
json+=",\"$p_trimmed\""
|
||||
fi
|
||||
done
|
||||
json+=']'
|
||||
echo "projects=$json" >> "$GITHUB_OUTPUT"
|
||||
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
project: ${{ fromJson(needs.build.outputs.projects) }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Download dist artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: dist
|
||||
path: ./
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Determine version and npm tag
|
||||
id: set-version
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
if [ -n "${{ github.event.inputs.version }}" ]; then
|
||||
VERSION="${{ github.event.inputs.version }}"
|
||||
else
|
||||
echo "No version provided for manual dispatch. Exiting." >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
fi
|
||||
if [ -n "${{ github.event.inputs.npm_tag }}" ]; then
|
||||
NPM_TAG="${{ github.event.inputs.npm_tag }}"
|
||||
else
|
||||
if echo "$VERSION" | grep -q "-"; then
|
||||
NPM_TAG="next"
|
||||
else
|
||||
NPM_TAG="latest"
|
||||
fi
|
||||
fi
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "npm_tag=$NPM_TAG" >> "$GITHUB_OUTPUT"
|
||||
- name: Configure npm auth
|
||||
run: |
|
||||
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
- name: Publish project
|
||||
run: |
|
||||
echo "Publishing ${{ matrix.project }} with version ${VERSION} and tag ${NPM_TAG}"
|
||||
node tools/scripts/publish.mjs "${{ matrix.project }}" "${VERSION}" "${NPM_TAG}"
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
Reference in New Issue
Block a user