diff --git a/.github/workflows/regenerate.yml b/.github/workflows/regenerate.yml index 65668e3..018594e 100644 --- a/.github/workflows/regenerate.yml +++ b/.github/workflows/regenerate.yml @@ -1,8 +1,9 @@ name: Regenerate -# Once a day, checks for a new release of the template. When there is one, every release branch is replaced -# by a fresh generation from it; the commits between releases never reach them. A branch with a "ref" in -# variants.json (nightly) follows that branch of the template instead and is replaced when it has moved. +# Once a day, checks the template's master: whatever reaches master is a release, tagged by its release.yml. +# When master carries a release these samples are not generated from yet, every release branch is replaced +# by a fresh generation from that tag. A branch with a "ref" in variants.json (nightly, on dev) follows that +# branch of the template instead and is replaced when it has moved. # # The branches carry workflow files, which GITHUB_TOKEN may not push, and a push by GITHUB_TOKEN starts no # workflows. The push uses SAMPLES_DEPLOY_KEY, a deploy key of this repository with write access: it does @@ -41,9 +42,12 @@ jobs: GH_TOKEN: ${{ github.token }} FORCE: ${{ inputs.force }} run: | - tag=$(gh release view -R "$TEMPLATE_REPO" --json tagName -q .tagName) + # The release is the tag on master's last commit. None there yet: release.yml is still publishing it, + # and the release branches wait for the next check. + master=$(gh api "repos/$TEMPLATE_REPO/commits/master" -q .sha) + tag=$(gh api "repos/$TEMPLATE_REPO/tags" --paginate -q ".[] | select(.commit.sha == \"$master\") | .name" | head -1) here=$(cat template-version 2>/dev/null || echo none) - echo "latest release $tag, release samples from $here" + echo "master ${master:0:7} is release ${tag:-(not tagged yet)}, release samples from $here" echo "tag=$tag" >> "$GITHUB_OUTPUT" todo='[]' for row in $(jq -c '.[] | {branch, ref}' .samples/variants.json); do @@ -54,6 +58,7 @@ jobs: have=$(gh api "repos/$GITHUB_REPOSITORY/contents/template-version?ref=$branch" -q .content 2>/dev/null | base64 -d || echo none) from="$ref" else + [ -n "$tag" ] || { echo "$branch: waits for master to be tagged"; continue; } want="$tag"; have="$here"; from="$tag" fi echo "$branch: $have -> $want" diff --git a/.samples/generate.sh b/.samples/generate.sh index 772d9c7..e05e83d 100644 --- a/.samples/generate.sh +++ b/.samples/generate.sh @@ -79,9 +79,9 @@ if [ "$(jq -r --arg b "$branch" '.[] | select(.branch == $b) | .default // false repo="https://github.com/${GITHUB_REPOSITORY:-sawking-tech/DotNetSolutionKit.Samples}" jq -r --arg r "$repo" '.[] | "| [`\(.branch)`](\($r)/tree/\(.branch)) | \(.about) | [![CI](\($r)/actions/workflows/ci.yml/badge.svg?branch=\(.branch))](\($r)/actions/workflows/ci.yml?query=branch%3A\(.branch)) |"' "$here/variants.json" echo - echo "Once a day [regenerate](.github/workflows/regenerate.yml) checks for a new release of the template." - echo "When there is one, every release branch is generated again from it and pushed, and its CI runs." - echo "nightly follows master instead: it is generated again when master has moved, and may be red." + echo "Once a day [regenerate](.github/workflows/regenerate.yml) checks the template's master: what reaches" + echo "master is a release, and every release branch is generated again from a new one, pushed, and its CI runs." + echo "nightly follows dev instead, where the next release is built: it is generated again when dev has moved." echo "After each CI run of a branch, [report](.github/workflows/report.yml) writes the run into the branch's" echo "reports// folder: tests, coverage, time and the branch's files, one file per release." echo "The automation is in [.samples](.samples)." diff --git a/.samples/variants.json b/.samples/variants.json index 19eb689..0d7677f 100644 --- a/.samples/variants.json +++ b/.samples/variants.json @@ -26,8 +26,8 @@ }, { "branch": "nightly", - "ref": "master", - "about": "The flags of full, generated from the template's master once a day when it has moved. A red CI here is a break in master before a release.", + "ref": "dev", + "about": "The flags of full, generated from the template's dev once a day when it has moved. A red CI here is a break in dev before a release.", "generate": [ "-N ST -P DotNetSolutionKit.Samples -S Orders -M false --GitHubCiCd true --Messaging outbox -I true --DiffApi true --FeatureFlags true --HierarchyRules true --Storage true --ClickHouse true", "-N ST -P DotNetSolutionKit.Samples -S Billing --Messaging outbox -I true --DiffApi true --FeatureFlags true --Storage true --ClickHouse true"