# Copyright 2026 jCloud # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. name: Release package on: release: types: - published permissions: contents: read jobs: build: name: Build package runs-on: python steps: - uses: actions/checkout@v4 - name: Build package run: | python3 -m build - name: Upload artifact uses: christopherhx/gitea-upload-artifact@v4 with: name: build-output path: | dist/*.tar.gz dist/*.whl prepare_upload_release_asset: name: Prepare release asset upload runs-on: debian outputs: files: ${{ steps.files.outputs.files }} steps: - name: Download artifact uses: christopherhx/gitea-download-artifact@v4 with: name: build-output path: dist/ - id: files shell: bash run: | files=$(node --input-type=module -e ' import { glob } from "node:fs/promises"; const files = await Array.fromAsync(glob([ "dist/*.tar.gz", "dist/*.whl" ])); console.log(JSON.stringify(files)); ') echo "files=$files" >> "$GITHUB_OUTPUT" upload_release_asset: name: Upload release asset runs-on: debian needs: [build, prepare_upload_release_asset] strategy: matrix: file: ${{ fromJSON(needs.prepare_upload_release_asset.outputs.files) }} steps: - uses: ${{ gitea.server_url }}/jCloud/actions/upload-release-asset@60d1ae076c2e1802e4bc9461e26c42c557652811 with: file: ${{ matrix.file }} release: ${{ gitea.event.release.id }} env: GITEA_TOKEN: ${{ secrets.RELEASE_ASSET_TOKEN }} publish: if: ${{ !github.event.release.prerelease && !github.event.release.draft }} name: Publish package to package registry runs-on: debian needs: build steps: - name: Download artifact uses: christopherhx/gitea-download-artifact@v4 with: name: build-output path: dist/ - name: Upload package env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.REGISTRY_TOKEN }} run: | python3 -m twine upload \ --repository-url ${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/pypi \ --disable-progress-bar \ dist/*