diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 0f43325..c802676 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -15,4 +15,38 @@ Releases When running the workflow manually on the `main` branch, a new release is created. The version is computed by removing the `-SNAPSHOT` suffix. The workflow creates a tag and attaches the release artifacts to it. -Afterwards the next snapshot-version is created and pushed. \ No newline at end of file +It also uses the pinned +[`release-plugins` action](https://github.com/CoreMedia/oci-tooling/tree/v0.2.1/actions/release-plugins) +to publish the plugin ZIPs as OCI artifacts to the public registry. Dry runs +skip this step; real releases require the registry secrets described below. +Afterwards the next snapshot-version is created and pushed. + +Republishing existing releases as OCI +------------------------------------- +Run **Republish Release as OCI** (`republish-release-as-oci.yml`) from the +Actions tab on the default branch. Enter an existing release version such as +`v3.0.0` or `3.0.0`, then select `public` (the default) or `ephemeral` for a +trial publication. Both options push artifacts; neither is a dry run. +Manual runs started from any other branch are skipped. + +The workflow uses the pinned +[`republish-plugins` action](https://github.com/CoreMedia/oci-tooling/tree/v0.2.1/actions/republish-plugins). +It reads this repository's `v` release using the built-in GitHub +token with `contents: read`. The release must contain +`query-service-.json` with URL-based plugin entries and all ZIP +assets referenced by that descriptor. No source checkout, Maven build, new +Git tag, or GitHub release is created. + +Two organization or repository secret pairs must be available to this +repository: `NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_USERNAME` and +`NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_PASSWORD` for the public registry, and +`NEXUS_GITHUB_ACTIONS_INTERNAL_IMAGES_USER` and +`NEXUS_GITHUB_ACTIONS_INTERNAL_IMAGES_PASSWORD` for the ephemeral registry. +The workflows use the pair matching the target registry. Public artifacts are pushed through +`repository.coremedia.com/public-images` and pulled from +`container-registry.coremedia.com`; ephemeral artifacts use +`repository.coremedia.com/ephemeral-images` and +`ephemeral-container-registry.coremedia.com`, respectively. +The descriptor reference is +`/plugins/query-service:` (without the `v` prefix). +The action logs the resulting artifact references. \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f9efcb9..6b0d29f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,17 @@ jobs: contents: write steps: + - name: Validate OCI registry credentials + if: ${{ !inputs.dry_run }} + env: + REGISTRY_USERNAME: ${{ secrets.NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_PASSWORD }} + run: | + if [[ -z "$REGISTRY_USERNAME" || -z "$REGISTRY_PASSWORD" ]]; then + echo "::error::NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_USERNAME and NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_PASSWORD must be configured." + exit 1 + fi + - name: Checkout uses: actions/checkout@v4 with: @@ -120,6 +131,21 @@ jobs: done echo "${RESULT}" > "target/bundle/query-service-${VERSION}.json" + - name: Publish OCI plugin artifacts + if: ${{ !inputs.dry_run }} + uses: CoreMedia/oci-tooling/actions/release-plugins@c91dc8dd03c9b6d1b0f13ee5d2cb3da42d9dc83a # v0.2.1 + with: + plugin-name: query-service + plugin-descriptor: query-service.json + version: ${{ steps.set-release-version.outputs.version }} + registry-username: ${{ secrets.NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_USERNAME }} + registry-password: ${{ secrets.NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_PASSWORD }} + + - name: Remove OCI build files + # keep them out of the next snapshot version commit + if: ${{ !inputs.dry_run }} + run: rm -rf .oci-build build-plugin.sh + - name: Set Next Snapshot Version if: ${{ github.event.inputs.dry_run == 'false' }} id: set-snapshot-version diff --git a/.github/workflows/republish-release-as-oci.yml b/.github/workflows/republish-release-as-oci.yml new file mode 100644 index 0000000..d16c95f --- /dev/null +++ b/.github/workflows/republish-release-as-oci.yml @@ -0,0 +1,66 @@ +name: Republish Release as OCI + +on: + workflow_dispatch: + inputs: + version: + description: 'Existing release version (e.g., v3.0.0 or 3.0.0)' + type: string + required: true + target-registry: + description: 'Target registry (ephemeral also publishes; it is not a dry run)' + type: choice + required: true + default: public + options: + - public + - ephemeral + +permissions: + contents: read + +jobs: + republish: + name: Republish existing release + # guards against accidental runs from other branches; it does not protect + # the secrets (that requires an environment with a deployment branch rule) + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + + steps: + - name: Validate inputs and registry credentials + id: validate + env: + RELEASE_VERSION: ${{ inputs.version }} + TARGET_REGISTRY: ${{ inputs.target-registry }} + REGISTRY_USERNAME: ${{ (inputs.target-registry == 'public' && secrets.NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_USERNAME) || (inputs.target-registry == 'ephemeral' && secrets.NEXUS_GITHUB_ACTIONS_INTERNAL_IMAGES_USER) || '' }} + REGISTRY_PASSWORD: ${{ (inputs.target-registry == 'public' && secrets.NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_PASSWORD) || (inputs.target-registry == 'ephemeral' && secrets.NEXUS_GITHUB_ACTIONS_INTERNAL_IMAGES_PASSWORD) || '' }} + run: | + VERSION="${RELEASE_VERSION#v}" + if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z]+([.-][0-9A-Za-z]+)*)?$ ]]; then + echo "::error::Version must be X.Y.Z with an optional v prefix and release suffix." + exit 1 + fi + if [[ "$TARGET_REGISTRY" != public && "$TARGET_REGISTRY" != ephemeral ]]; then + echo "::error::Target registry must be public or ephemeral." + exit 1 + fi + if [[ -z "$REGISTRY_USERNAME" || -z "$REGISTRY_PASSWORD" ]]; then + if [[ "$TARGET_REGISTRY" == public ]]; then + echo "::error::NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_USERNAME and NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_PASSWORD must be configured." + else + echo "::error::NEXUS_GITHUB_ACTIONS_INTERNAL_IMAGES_USER and NEXUS_GITHUB_ACTIONS_INTERNAL_IMAGES_PASSWORD must be configured." + fi + exit 1 + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Republish release assets as OCI artifacts + uses: CoreMedia/oci-tooling/actions/republish-plugins@c91dc8dd03c9b6d1b0f13ee5d2cb3da42d9dc83a # v0.2.1 + with: + plugin-name: query-service + version: ${{ steps.validate.outputs.version }} + github-token: ${{ github.token }} + registry-username: ${{ (inputs.target-registry == 'public' && secrets.NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_USERNAME) || (inputs.target-registry == 'ephemeral' && secrets.NEXUS_GITHUB_ACTIONS_INTERNAL_IMAGES_USER) || '' }} + registry-password: ${{ (inputs.target-registry == 'public' && secrets.NEXUS_GITHUB_ACTIONS_IMAGE_RELEASES_PASSWORD) || (inputs.target-registry == 'ephemeral' && secrets.NEXUS_GITHUB_ACTIONS_INTERNAL_IMAGES_PASSWORD) || '' }} + target-registry: ${{ inputs.target-registry }}