Author SHA1 Message Date
Gabriel20xx dfae1cb572 Bump Go and Python package release to 0.1.1
Publish Go package / Publish shared Go module (push) Successful in 57s
Publish npm packages / Publish shared npm packages (push) Failing after 39s
Publish Python package / Publish shared Python package (push) Successful in 12s
2026-08-06 12:12:04 +02:00
Gabriel20xx 752f3ba433 Fix Go and Python package publishing workflows 2026-08-06 12:07:26 +02:00
Gabriel20xx 72a5e289f6 Add npm and Python package publishing workflows
Publish npm packages / Publish shared npm packages (push) Successful in 16s
Publish Python package / Publish shared Python package (push) Failing after 16s
2026-08-06 11:34:52 +02:00
Gabriel20xx 01401cb1cd Make release retry independent of tag script version 2026-08-06 10:59:26 +02:00
Gabriel20xx d3cb76dc32 Add Gitea release trigger for Go package publishing 2026-08-06 10:58:20 +02:00
Gabriel20xx 61b1eda37d Fix Go package output path handling 2026-08-06 10:40:23 +02:00
6 changed files with 196 additions and 28 deletions

No files matched your search

+30 -5
View File
@@ -4,6 +4,9 @@ on:
push:
tags:
- 'backend/v*'
release:
types:
- published
jobs:
publish:
@@ -32,8 +35,13 @@ jobs:
- name: Package Go module
env:
RELEASE_TAG: ${{ github.ref_name }}
run: bash scripts/package-go-module.sh "$RELEASE_TAG" "$RUNNER_TEMP/gitea-go-package"
RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }}
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
env:
@@ -46,8 +54,25 @@ jobs:
echo 'PACKAGE_REGISTRY_USERNAME and PACKAGE_REGISTRY_TOKEN secrets are required.' >&2
exit 1
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"
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" \
"$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
+66
View File
@@ -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
+74
View File
@@ -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[@]}"
+18 -20
View File
@@ -59,31 +59,29 @@ SharedCode version has been validated.
## 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:
```bash
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.
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.
The Python workflow uses Twine's `--skip-existing` option for the same reason.
## 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
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:
```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:
@@ -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.
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:
```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
python -m pip install build
python -m build packages/python-backend
python -m pip install gabriel20xx-shared-backend==0.1.0
python -m pip install \
--index-url "https://$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN@repos.gfranz.ch/api/packages/Gabriel20xx/pypi/simple" \
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.
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "gabriel20xx-shared-backend"
version = "0.1.0"
version = "0.1.1"
description = "Shared PostgreSQL and authentication primitives for Python services."
readme = "README.md"
requires-python = ">=3.10"
+7 -2
View File
@@ -33,8 +33,13 @@ git archive --format=tar "$release_tag" "$module_directory" \
test -f "$module_root/go.mod"
grep -Fxq "module $module_path" "$module_root/go.mod"
mkdir -p "$repository_root/$output_directory"
zip_file="$repository_root/$output_directory/${module_path//\//_}@${version}.zip"
if [[ "$output_directory" = /* ]]; then
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"
(