mirror of
https://github.com/walter-base/common-workflow.git
synced 2026-09-08 19:26:46 -04:00
120 lines
3.9 KiB
YAML
120 lines
3.9 KiB
YAML
name: Release agent marketplace
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
target_branch:
|
|
description: Branch that receives release-please changes.
|
|
required: false
|
|
type: string
|
|
default: main
|
|
release_config_file:
|
|
description: Path to the release-please configuration file.
|
|
required: true
|
|
type: string
|
|
release_manifest_file:
|
|
description: Path to the release-please manifest file.
|
|
required: true
|
|
type: string
|
|
package_paths:
|
|
description: Space-separated paths to include in the marketplace archive.
|
|
required: true
|
|
type: string
|
|
archive_name:
|
|
description: Base name for the marketplace archive.
|
|
required: true
|
|
type: string
|
|
publish_gitea:
|
|
description: Upload the released archive to Gitea and write its URL to the summary.
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
gitea_url:
|
|
description: Base URL of the Gitea instance.
|
|
required: false
|
|
type: string
|
|
default: ""
|
|
gitea_user:
|
|
description: Gitea user or organization that owns the generic package.
|
|
required: false
|
|
type: string
|
|
default: ""
|
|
secrets:
|
|
GITEA_TOKEN:
|
|
description: Gitea token with permission to publish generic packages.
|
|
required: false
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
release-please:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
release_created: ${{ steps.release.outputs.release_created }}
|
|
tag_name: ${{ steps.release.outputs.tag_name }}
|
|
version: ${{ steps.release.outputs.version }}
|
|
steps:
|
|
- name: Create or update release PR
|
|
id: release
|
|
uses: googleapis/release-please-action@v4
|
|
with:
|
|
token: ${{ secrets.GITHUB_PAT || github.token }}
|
|
target-branch: ${{ inputs.target_branch }}
|
|
config-file: ${{ inputs.release_config_file }}
|
|
manifest-file: ${{ inputs.release_manifest_file }}
|
|
|
|
publish:
|
|
needs: release-please
|
|
if: inputs.publish_gitea && needs.release-please.outputs.release_created == 'true'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Check out released marketplace
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ needs.release-please.outputs.tag_name }}
|
|
|
|
- name: Build marketplace archive
|
|
env:
|
|
ARCHIVE_NAME: ${{ inputs.archive_name }}
|
|
PACKAGE_PATHS: ${{ inputs.package_paths }}
|
|
VERSION: ${{ needs.release-please.outputs.tag_name }}
|
|
run: |
|
|
read -r -a paths <<< "$PACKAGE_PATHS"
|
|
tar -czf "${ARCHIVE_NAME}-${VERSION}.tar.gz" "${paths[@]}"
|
|
|
|
- name: Upload archive to Gitea
|
|
env:
|
|
ARCHIVE_NAME: ${{ inputs.archive_name }}
|
|
GITEA_URL: ${{ inputs.gitea_url }}
|
|
GITEA_USER: ${{ inputs.gitea_user }}
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
VERSION: ${{ needs.release-please.outputs.tag_name }}
|
|
run: |
|
|
: "${GITEA_URL:?Set gitea_url when publish_gitea is enabled}"
|
|
: "${GITEA_USER:?Set gitea_user when publish_gitea is enabled}"
|
|
: "${GITEA_TOKEN:?Pass GITEA_TOKEN when publish_gitea is enabled}"
|
|
archive="${ARCHIVE_NAME}-${VERSION}.tar.gz"
|
|
package_url="${GITEA_URL%/}/api/packages/${GITEA_USER}/generic/${ARCHIVE_NAME}/${VERSION}/${archive}"
|
|
curl --fail-with-body --retry 3 \
|
|
--user "${GITEA_USER}:${GITEA_TOKEN}" \
|
|
--upload-file "$archive" \
|
|
"$package_url"
|
|
|
|
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
|
|
# Agent Marketplace ${VERSION}
|
|
|
|
Download the marketplace archive from Gitea:
|
|
|
|
${package_url}
|
|
|
|
```bash
|
|
curl --user "GITEA_USER:GITEA_TOKEN" \\
|
|
--output "${archive}" \\
|
|
"${package_url}"
|
|
```
|
|
EOF
|