Files
pluginBase/.gitea/workflows/release.yml
T
lyuksovannyy 965fb5a284
Publish plugin / publish (push) Failing after 4s
Read the release token from RELEASE_TOKEN
The publish step set GITEA_TOKEN from the org-level API_TOKEN secret, but
the Actions runner injects its own GITEA_TOKEN into every step and that
value overrides a step-level env: entry of the same name. The org secret
was silently ignored and the job failed.

Pass the secret as RELEASE_TOKEN instead, which the runner does not
reserve, and read that name in release.py. --token-env makes the source
configurable, so the runner-provided GITEA_TOKEN can still be used
deliberately by passing --token-env GITEA_TOKEN.
2026-09-13 00:10:07 +02:00

86 lines
3.2 KiB
YAML

name: Publish plugin
# Builds dist/<id>.plugin and publishes it to the Releases tab.
#
# The version in plugin.json is the single source of truth:
# new version -> a new v<version> tag and release are created
# same version -> the existing release is rebuilt, replacing its attachment
#
# So a normal push to main always produces a downloadable build, and bumping
# the version in plugin.json is what cuts a new release. Pushing a v* tag by
# hand still works and uses that tag verbatim.
#
# dist/ is gitignored, so the artifact is always built here rather than
# committed. The build uses --release because --dev embeds absolute paths from
# whichever machine produced it.
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Check out sources
uses: actions/checkout@v4
- name: Validate plugin metadata and sources
run: python3 tools/bundle.py --check
- name: Build release bundle
id: build
run: |
set -eu
python3 tools/bundle.py --release
plugin_id=$(python3 -c "import json; print(json.load(open('plugin.json'))['id'])")
version=$(python3 -c "import json; print(json.load(open('plugin.json'))['version'])")
artifact="dist/${plugin_id}.plugin"
test -s "$artifact"
echo "artifact=${artifact}" >> "$GITHUB_OUTPUT"
echo "asset_name=${plugin_id}.plugin" >> "$GITHUB_OUTPUT"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "built ${artifact} ($(wc -c < "$artifact") bytes)"
- name: Verify the built bundle
# Executes the bundle against faked SDK modules and asserts the
# plugin's observable behaviour. A build that fails this is not
# publishable, so this gates the upload.
run: python3 tools/verify_bundle.py "${{ steps.build.outputs.artifact }}"
- name: Resolve release tag
id: tag
run: |
set -eu
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
# Hand-pushed tag: honour it exactly as written.
tag="${GITHUB_REF_NAME}"
else
# Branch push or manual run: the version in plugin.json decides
# whether this is a new release or a rebuild of the current one.
tag="v${{ steps.build.outputs.version }}"
fi
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
echo "publishing as ${tag}"
- name: Publish release and upload plugin
env:
# Deliberately not named GITEA_TOKEN: the Actions runner injects its
# own GITEA_TOKEN into every step, and that value wins over a
# step-level `env:` of the same name, so the org secret would be
# silently ignored.
RELEASE_TOKEN: ${{ secrets.API_TOKEN }}
run: |
python3 tools/release.py \
--api "${{ github.server_url }}/api/v1/repos/${{ github.repository }}" \
--tag "${{ steps.tag.outputs.tag }}" \
--artifact "${{ steps.build.outputs.artifact }}" \
--asset-name "${{ steps.build.outputs.asset_name }}" \
--commitish "${{ github.sha }}"