Files
AareDAQ/.gitea/workflows/publish.yml
T
perl_d 110bfb3f5f
CI / lint (pull_request) Successful in 38s
CI / test (3.11) (pull_request) Successful in 1m23s
CI / test (3.12) (pull_request) Successful in 1m22s
CI / test (3.13) (pull_request) Successful in 1m23s
CI / test-with-beamline-plugins (pxi_bec) (pull_request) Successful in 1m27s
CI / test-with-beamline-plugins (pxii_bec) (pull_request) Successful in 1m32s
CI / test-with-beamline-plugins (pxiii_bec) (pull_request) Successful in 1m41s
CI / test-with-coverage (pull_request) Successful in 2m8s
CI / lint (push) Successful in 34s
Docs build and publish / docker (push) Successful in 6s
Build and Publish / release (push) Successful in 12s
CI / test (3.13) (push) Canceled after 1m15s
CI / test (3.11) (push) Canceled after 1m20s
CI / test (3.12) (push) Canceled after 1m15s
CI / test-with-beamline-plugins (pxi_bec) (push) Canceled after 1m10s
CI / test-with-beamline-plugins (pxii_bec) (push) Canceled after 1m10s
CI / test-with-beamline-plugins (pxiii_bec) (push) Canceled after 56s
CI / test-with-coverage (push) Canceled after 45s
CI / coverage-analysis (push) Canceled after 0s
CI / coverage-analysis (pull_request) Successful in 6s
fix: allow workflow dispatch of release wf
2026-08-11 13:38:48 +02:00

86 lines
3.0 KiB
YAML

name: Build and Publish
on:
push:
branches:
- main
workflow-dispatch:
jobs:
release:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-release-${{ github.ref_name }}
cancel-in-progress: false
outputs:
release_made: ${{ steps.release_step.outputs.release_made }}
permissions:
contents: write
steps:
- name: Setup | Checkout Repository on Release Branch
uses: actions/checkout@v6
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Setup | Force release branch to be at workflow sha
run: |
git reset --hard ${{ github.sha }}
- name: Evaluate | Verify upstream has NOT changed
shell: bash
env:
MX_GITEA_BOT_TOKEN: ${{ secrets.MX_GITEA_BOT_TOKEN }}
run: |
set +o pipefail
UPSTREAM_BRANCH_NAME="$(git status -sb | head -n 1 | cut -d' ' -f2 | grep -E '\.{3}' | cut -d'.' -f4)"
printf '%s\n' "Upstream branch name: $UPSTREAM_BRANCH_NAME"
set -o pipefail
if [ -z "$UPSTREAM_BRANCH_NAME" ]; then
printf >&2 '%s\n' "::error::Unable to determine upstream branch name!"
exit 1
fi
# checkout ran with persist-credentials: false, so the remote carries no
# credentials; give it the bot token to reach this private repo.
git remote set-url "${UPSTREAM_BRANCH_NAME%%/*}" \
"https://${MX_GITEA_BOT_TOKEN}@gitea.psi.ch/${{ github.repository }}.git"
git fetch "${UPSTREAM_BRANCH_NAME%%/*}"
if ! UPSTREAM_SHA="$(git rev-parse "$UPSTREAM_BRANCH_NAME")"; then
printf >&2 '%s\n' "::error::Unable to determine upstream branch sha!"
exit 1
fi
HEAD_SHA="$(git rev-parse HEAD)"
if [ "$HEAD_SHA" != "$UPSTREAM_SHA" ]; then
printf >&2 '%s\n' "[HEAD SHA] $HEAD_SHA != $UPSTREAM_SHA [UPSTREAM SHA]"
printf >&2 '%s\n' "::error::Upstream has changed, aborting release..."
exit 1
fi
printf '%s\n' "Verified upstream branch has not changed, continuing with release..."
- name: Semantic Version Release
id: release_step
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.MX_GITEA_BOT_TOKEN }}
MX_GITEA_BOT_TOKEN: ${{ secrets.MX_GITEA_BOT_TOKEN }}
run: |
pip install python-semantic-release==9.* wheel build twine
semantic-release --config ./ci/semantic_release.toml version
if [ ! -d dist ]; then echo No release will be made; echo "release_made=false" >> "$GITHUB_OUTPUT"; exit 0; fi
echo "release_made=true" >> "$GITHUB_OUTPUT"
twine upload dist/* --repository-url https://gitea.psi.ch/api/packages/mx/pypi
semantic-release publish