Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/regenerate.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions .samples/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/<branch>/ folder: tests, coverage, time and the branch's files, one file per release."
echo "The automation is in [.samples](.samples)."
Expand Down
4 changes: 2 additions & 2 deletions .samples/variants.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading