name: Publish project release action # Thin caller onto the hub's reusable plan, validate, build-release, and Docker Hub readme tasks, per ptr727/ProjectTemplate docs/reusable-workflows.md "Adopting the Release Chain". # One run publishes one branch, the trigger ref, so github.ref stays aligned with the branch NBGV versions. # The weekly schedule rebuilds main, refreshing the shared base images for CVEs and cutting a versioned GitHub release. # A path-scoped push publishes main as soon as the codegen App commits a new Make/Matrix.json pin, so a new upstream product version ships at once. # A manual dispatch publishes the branch it is started from, main as the stable channel and develop as the develop tags. # # Ordinary code merges do not publish: the plan task publishes a push only when a bot made it, so a human pin edit does not. # The daily develop codegen pin update is sync-only, since the push trigger is main-only. # Refresh the develop tags by dispatching from develop. # The Docker matrix comes from Make/Matrix.json through the repo's own docker-prepare hook. on: workflow_dispatch: schedule: # Weekly rebuild and publish of main, Monday 02:00 UTC, to pick up shared base-image updates. - cron: '0 2 * * MON' push: branches: [main] paths: [Make/Matrix.json] # A ref-scoped group, per WORKFLOW.md D7.1, so a schedule, a dispatch, and a pin push on one ref queue rather than race. # The main and develop runs push disjoint tags, since a develop publish pushes only the develop tags and no base image or readme. # A push the plan does not publish takes its own group, so it never replaces a pending publish. # That is a push off main, or one by an actor off publish-plan-task.yml's allowlist. # With cancel-in-progress false, a queued run never cancels a partial push. concurrency: group: ${{ github.workflow }}-${{ github.ref }}${{ github.event_name == 'push' && (github.ref != 'refs/heads/main' || (github.actor != 'ptr727-codegen[bot]' && github.actor != 'dependabot[bot]')) && format('-{0}', github.run_id) || '' }} cancel-in-progress: false # GITHUB_TOKEN gets no scope by default, and each job below grants only what its task writes with. permissions: {} jobs: # Single source of the release-gate decision (publish or not, stable or not), reused by every job below. plan: name: Plan release job uses: ptr727/ProjectTemplate/.github/workflows/publish-plan-task.yml@df04adaee6c5928177535e40eb5b9310638f501e # 2.0.1343 with: event_name: ${{ github.event_name }} actor: ${{ github.actor }} ref_name: ${{ github.ref_name }} # The same reusable gate the push CI runs, on the triggering commit, running only when a publish will happen. validate: name: Validate job needs: [plan] if: ${{ needs.plan.outputs.publish == 'true' }} uses: ptr727/ProjectTemplate/.github/workflows/validate-task.yml@df04adaee6c5928177535e40eb5b9310638f501e # 2.0.1343 permissions: contents: read secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # The shared base images carry one branch-agnostic tag, so only a main publish builds and pushes them, and a develop publish reuses main's. # This job rather than the hub's build-base leg pushes them, since that leg holds no Docker Hub login and a composite hook cannot read secrets. build-base: name: Build base image job needs: [plan, validate] if: ${{ needs.plan.outputs.stable == 'true' && needs.validate.result == 'success' }} runs-on: ubuntu-latest permissions: contents: read steps: - name: Checkout code step uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} - name: Login to Docker Hub step uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Build and push base images step uses: ./.github/actions/docker-build-base with: push: true # Version, build, and push every Make/Matrix.json row of the trigger branch, then cut the GitHub release on main. # build-base is an optional dependency, skipped on a develop publish, so its result is allowlisted as success or skipped explicitly. # The !cancelled() replaces the implicit success() that would otherwise skip this job whenever build-base is skipped. publish: name: Publish project release job needs: [plan, validate, build-base] if: >- ${{ !cancelled() && needs.plan.outputs.publish == 'true' && needs.validate.result == 'success' && (needs.build-base.result == 'success' || needs.build-base.result == 'skipped') }} uses: ptr727/ProjectTemplate/.github/workflows/build-release-task.yml@df04adaee6c5928177535e40eb5b9310638f501e # 2.0.1343 permissions: contents: write # Lets the hub github-release job delete its transfer artifacts (D5.1), though a Docker-only release uploads none. actions: write secrets: DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} with: # Pin to the triggering commit rather than the moving branch tip, so the version, the images, and the release tag share one commit. ref: ${{ github.sha }} branch: ${{ github.ref_name }} smoke: false # A develop publish pushes images and the develop tags but cuts no GitHub release. github: ${{ needs.plan.outputs.stable == 'true' }} dockerhub: true enable_docker: true enable_dotnet_publish: false enable_nuget: false enable_pypi: false # The images are the published artifact, so the release carries only the tag, the source zip, README, and LICENSE. expect_release_assets: false # The build-base job above already built the shared base, or a develop publish reuses main's. docker_build_base: false # Docker Hub does not read the GitHub README, so the overview is pushed to every product repository and both base repositories. # The hub task pushes only on main, and publishes Docker/README.md, the Docker Hub overview. publish-docker-readme: name: Publish Docker Hub readme job needs: [plan, publish] if: ${{ needs.plan.outputs.stable == 'true' && needs.publish.result == 'success' }} permissions: contents: read uses: ptr727/ProjectTemplate/.github/workflows/publish-docker-readme-task.yml@df04adaee6c5928177535e40eb5b9310638f501e # 2.0.1343 with: ref: ${{ github.sha }} branch: ${{ github.ref_name }} manifest: ./Make/Matrix.json manifest-jq: '[.Images[].Name | ascii_downcase | "ptr727/\(.)"] + ["ptr727/nx-base","ptr727/nx-base-lsio"] | sort | unique' secrets: DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}