Compare commits
6
Commits
backend/v0.1.0
...
v0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfae1cb572 | ||
|
|
752f3ba433 | ||
|
|
72a5e289f6 | ||
|
|
01401cb1cd | ||
|
|
d3cb76dc32 | ||
|
|
61b1eda37d |
No files matched your search
@@ -4,6 +4,9 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'backend/v*'
|
- 'backend/v*'
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
@@ -32,8 +35,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Package Go module
|
- name: Package Go module
|
||||||
env:
|
env:
|
||||||
RELEASE_TAG: ${{ github.ref_name }}
|
RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }}
|
||||||
run: bash scripts/package-go-module.sh "$RELEASE_TAG" "$RUNNER_TEMP/gitea-go-package"
|
run: |
|
||||||
|
package_directory='gitea-go-package'
|
||||||
|
rm -rf "$package_directory"
|
||||||
|
mkdir -p "$package_directory"
|
||||||
|
bash scripts/package-go-module.sh "$RELEASE_TAG" "$package_directory"
|
||||||
|
find "$package_directory" -maxdepth 1 -type f -name '*.zip' -print -quit | grep -q .
|
||||||
|
|
||||||
- name: Publish to Gitea Package Registry
|
- name: Publish to Gitea Package Registry
|
||||||
env:
|
env:
|
||||||
@@ -46,8 +54,25 @@ jobs:
|
|||||||
echo 'PACKAGE_REGISTRY_USERNAME and PACKAGE_REGISTRY_TOKEN secrets are required.' >&2
|
echo 'PACKAGE_REGISTRY_USERNAME and PACKAGE_REGISTRY_TOKEN secrets are required.' >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
package_file="$(find "$RUNNER_TEMP/gitea-go-package" -maxdepth 1 -type f -name '*.zip' -print -quit)"
|
package_file="$(find gitea-go-package -maxdepth 1 -type f -name '*.zip' -print -quit)"
|
||||||
test -n "$package_file"
|
test -n "$package_file"
|
||||||
curl --fail-with-body --user "$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN" \
|
response_file="$(mktemp)"
|
||||||
|
http_status="$(curl --silent --show-error --fail-with-body \
|
||||||
|
--user "$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN" \
|
||||||
|
--output "$response_file" \
|
||||||
|
--write-out '%{http_code}' \
|
||||||
--upload-file "$package_file" \
|
--upload-file "$package_file" \
|
||||||
"$GITEA_GO_REGISTRY"
|
"$GITEA_GO_REGISTRY" || true)"
|
||||||
|
case "$http_status" in
|
||||||
|
201)
|
||||||
|
echo 'Go package published.'
|
||||||
|
;;
|
||||||
|
409)
|
||||||
|
echo 'Go package version already exists; leaving the immutable package unchanged.'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cat "$response_file" >&2
|
||||||
|
echo "Gitea Go package upload failed with HTTP status $http_status." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
name: Publish npm packages
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
name: Publish shared npm packages
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- name: Checkout source
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
cache: npm
|
||||||
|
|
||||||
|
- name: Install and build packages
|
||||||
|
run: |
|
||||||
|
npm ci
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
- name: Configure Gitea npm registry
|
||||||
|
env:
|
||||||
|
PACKAGE_REGISTRY_USERNAME: ${{ secrets.PACKAGE_REGISTRY_USERNAME }}
|
||||||
|
PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [ -z "$PACKAGE_REGISTRY_USERNAME" ] || [ -z "$PACKAGE_REGISTRY_TOKEN" ]; then
|
||||||
|
echo 'PACKAGE_REGISTRY_USERNAME and PACKAGE_REGISTRY_TOKEN secrets are required.' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
npmrc_path="$RUNNER_TEMP/gitea-npmrc"
|
||||||
|
umask 077
|
||||||
|
{
|
||||||
|
printf '@gabriel20xx:registry=https://repos.gfranz.ch/api/packages/Gabriel20xx/npm/\n'
|
||||||
|
printf '//repos.gfranz.ch/api/packages/Gabriel20xx/npm/:_authToken=%s\n' "$PACKAGE_REGISTRY_TOKEN"
|
||||||
|
printf 'always-auth=true\n'
|
||||||
|
} > "$npmrc_path"
|
||||||
|
printf 'NPM_CONFIG_USERCONFIG=%s\n' "$npmrc_path" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Publish npm packages
|
||||||
|
env:
|
||||||
|
NPM_REGISTRY: https://repos.gfranz.ch/api/packages/Gabriel20xx/npm/
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
for package in \
|
||||||
|
@gabriel20xx/design-tokens \
|
||||||
|
@gabriel20xx/web-ui \
|
||||||
|
@gabriel20xx/node-backend; do
|
||||||
|
version="$(npm pkg get version --workspace="$package" | tr -d '"[:space:]')"
|
||||||
|
if npm view "$package@$version" version --registry="$NPM_REGISTRY" >/dev/null 2>&1; then
|
||||||
|
echo "$package@$version is already published; skipping."
|
||||||
|
else
|
||||||
|
npm publish --workspace="$package" --registry="$NPM_REGISTRY"
|
||||||
|
fi
|
||||||
|
done
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
name: Publish Python package
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
name: Publish shared Python package
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- name: Checkout source
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.12'
|
||||||
|
|
||||||
|
- name: Build and publish package
|
||||||
|
env:
|
||||||
|
PACKAGE_REGISTRY_USERNAME: ${{ secrets.PACKAGE_REGISTRY_USERNAME }}
|
||||||
|
PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}
|
||||||
|
TWINE_REPOSITORY_URL: https://repos.gfranz.ch/api/packages/Gabriel20xx/pypi
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [ -z "$PACKAGE_REGISTRY_USERNAME" ] || [ -z "$PACKAGE_REGISTRY_TOKEN" ]; then
|
||||||
|
echo 'PACKAGE_REGISTRY_USERNAME and PACKAGE_REGISTRY_TOKEN secrets are required.' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
python -m pip install --disable-pip-version-check --no-cache-dir build twine
|
||||||
|
package_directory="$RUNNER_TEMP/gitea-pypi-package"
|
||||||
|
python -m build packages/python-backend --outdir "$package_directory"
|
||||||
|
package_index_url="${TWINE_REPOSITORY_URL%/}/simple/gabriel20xx-shared-backend/"
|
||||||
|
package_index_file="$(mktemp)"
|
||||||
|
package_index_status="$(curl --silent --show-error --fail-with-body \
|
||||||
|
--user "$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN" \
|
||||||
|
--output "$package_index_file" \
|
||||||
|
--write-out '%{http_code}' \
|
||||||
|
"$package_index_url" || true)"
|
||||||
|
package_files=("$package_directory"/*)
|
||||||
|
files_to_upload=()
|
||||||
|
case "$package_index_status" in
|
||||||
|
200)
|
||||||
|
for package_file in "${package_files[@]}"; do
|
||||||
|
if ! grep -Fq "$(basename "$package_file")" "$package_index_file"; then
|
||||||
|
files_to_upload+=("$package_file")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
404)
|
||||||
|
files_to_upload=("${package_files[@]}")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cat "$package_index_file" >&2
|
||||||
|
echo "Gitea PyPI package lookup failed with HTTP status $package_index_status." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ "${#files_to_upload[@]}" -eq 0 ]; then
|
||||||
|
echo 'Python package version already exists with all build artifacts; leaving it unchanged.'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
TWINE_USERNAME="$PACKAGE_REGISTRY_USERNAME" \
|
||||||
|
TWINE_PASSWORD="$PACKAGE_REGISTRY_TOKEN" \
|
||||||
|
python -m twine upload --non-interactive \
|
||||||
|
--repository-url "$TWINE_REPOSITORY_URL" \
|
||||||
|
"${files_to_upload[@]}"
|
||||||
@@ -59,31 +59,29 @@ SharedCode version has been validated.
|
|||||||
|
|
||||||
## Publish the individual packages
|
## Publish the individual packages
|
||||||
|
|
||||||
The package names use the `@gabriel20xx` npm scope. That scope must belong to the npm account used to publish. If a different scope is preferred, replace the scope consistently in both package manifests and imports before publishing.
|
The package names use the `@gabriel20xx` npm scope. The `publish-npm.yml` and
|
||||||
|
`publish-python.yml` Gitea workflows publish the packages when a `v*` tag is pushed or a
|
||||||
|
matching Gitea release is published. Configure `PACKAGE_REGISTRY_USERNAME` and
|
||||||
|
`PACKAGE_REGISTRY_TOKEN` as user Actions secrets before publishing.
|
||||||
|
|
||||||
Publish the tokens first because `web-ui` depends on them:
|
The npm workflow publishes `design-tokens` first because `web-ui` depends on it. It also
|
||||||
|
skips an npm version that is already present, so retrying a partially completed release is safe.
|
||||||
```bash
|
The Python workflow uses Twine's `--skip-existing` option for the same reason.
|
||||||
npm login
|
|
||||||
npm publish --workspace=@gabriel20xx/design-tokens --access public
|
|
||||||
npm publish --workspace=@gabriel20xx/web-ui --access public
|
|
||||||
npm publish --workspace=@gabriel20xx/node-backend --access public
|
|
||||||
```
|
|
||||||
|
|
||||||
For a private registry, configure that registry and omit `--access public` if the registry does not use npm's public scoped-package rules.
|
|
||||||
|
|
||||||
## Install individual packages from a registry
|
## Install individual packages from a registry
|
||||||
|
|
||||||
From a project's frontend directory, install the published UI package:
|
From a project's frontend directory, install the published UI package from Gitea:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @gabriel20xx/web-ui@^0.1.0
|
npm config set @gabriel20xx:registry https://repos.gfranz.ch/api/packages/Gabriel20xx/npm/
|
||||||
|
npm config set //repos.gfranz.ch/api/packages/Gabriel20xx/npm/:_authToken "$PACKAGE_REGISTRY_TOKEN"
|
||||||
|
npm install @gabriel20xx/web-ui@0.1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
The design-token package is installed transitively. Install it directly only when an application needs to reference its theme file itself:
|
The design-token package is installed transitively. Install it directly only when an application needs to reference its theme file itself:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @gabriel20xx/design-tokens@^0.1.0
|
npm install @gabriel20xx/design-tokens@0.1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
Import the shared stylesheet once from the application's global stylesheet, before project-specific overrides:
|
Import the shared stylesheet once from the application's global stylesheet, before project-specific overrides:
|
||||||
@@ -143,20 +141,20 @@ Use `auth.SchemaOptions{SingleUser: false, APITokens: true}` for a multi-user se
|
|||||||
|
|
||||||
For embedded SQL migrations, use `migrate.Up(ctx, databaseURL, embeddedMigrations, "migrations")`. The package does not contain application tables, so migrations remain versioned with the service that owns those tables.
|
For embedded SQL migrations, use `migrate.Up(ctx, databaseURL, embeddedMigrations, "migrations")`. The package does not contain application tables, so migrations remain versioned with the service that owns those tables.
|
||||||
|
|
||||||
The Go module lives under `backend`, so its release tag must use the submodule prefix (`backend/v0.1.0`). The consuming `go.mod` uses the normal module version (`v0.1.0`). To publish a release, push a tag such as `backend/v0.1.0`; the Gitea workflow packages the module and uploads it to the private registry. Never reuse an existing package version.
|
The Go module lives under `backend`, so its release tag must use the submodule prefix (`backend/v0.1.0`). The consuming `go.mod` uses the normal module version (`v0.1.0`). To publish a release, push a tag such as `backend/v0.1.0`; the Gitea workflow packages the module and uploads it to the private registry. The workflow also listens for Gitea's `release.published` event, so a release can be published from the Gitea Releases page to manually retry a failed upload for an existing tag. Never reuse a package version that was already uploaded successfully.
|
||||||
|
|
||||||
For Node services, install the shared package after publishing it:
|
For Node services, install the shared package after publishing it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @gabriel20xx/node-backend@^0.1.0
|
npm install @gabriel20xx/node-backend@0.1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
For Python services, build and publish the wheel to the Python package index used by the projects, then install it normally:
|
For Python services, configure the Gitea index and install the published wheel:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python -m pip install build
|
python -m pip install \
|
||||||
python -m build packages/python-backend
|
--index-url "https://$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN@repos.gfranz.ch/api/packages/Gabriel20xx/pypi/simple" \
|
||||||
python -m pip install gabriel20xx-shared-backend==0.1.0
|
gabriel20xx-shared-backend==0.1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
The Node and Python packages intentionally expose the same infrastructure concepts but use their native database drivers. This is the safe way to share behavior across the polyglot services; a Go package cannot be imported by the Python or Node applications.
|
The Node and Python packages intentionally expose the same infrastructure concepts but use their native database drivers. This is the safe way to share behavior across the polyglot services; a Go package cannot be imported by the Python or Node applications.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "gabriel20xx-shared-backend"
|
name = "gabriel20xx-shared-backend"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
description = "Shared PostgreSQL and authentication primitives for Python services."
|
description = "Shared PostgreSQL and authentication primitives for Python services."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
|
|||||||
@@ -33,8 +33,13 @@ git archive --format=tar "$release_tag" "$module_directory" \
|
|||||||
|
|
||||||
test -f "$module_root/go.mod"
|
test -f "$module_root/go.mod"
|
||||||
grep -Fxq "module $module_path" "$module_root/go.mod"
|
grep -Fxq "module $module_path" "$module_root/go.mod"
|
||||||
mkdir -p "$repository_root/$output_directory"
|
if [[ "$output_directory" = /* ]]; then
|
||||||
zip_file="$repository_root/$output_directory/${module_path//\//_}@${version}.zip"
|
output_path="$output_directory"
|
||||||
|
else
|
||||||
|
output_path="$repository_root/$output_directory"
|
||||||
|
fi
|
||||||
|
mkdir -p "$output_path"
|
||||||
|
zip_file="$output_path/${module_path//\//_}@${version}.zip"
|
||||||
rm -f "$zip_file"
|
rm -f "$zip_file"
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in new issue
Block a user