diff --git a/.github/workflows/reusable-publish-release.yml b/.github/workflows/reusable-publish-release.yml index bc76c30..c692d7b 100644 --- a/.github/workflows/reusable-publish-release.yml +++ b/.github/workflows/reusable-publish-release.yml @@ -172,12 +172,19 @@ jobs: done < "$RUNNER_TEMP/tags.txt" # Copy the source channel onto the published channel(s), preserving the others, then guard that - # every tag the published feed references exists before pushing. + # every tag the published feed references exists before pushing. On the first release the publish + # branch doesn't exist yet, so seed the worktree from the released commit and let the final push + # create it. - name: Publish to the publish branch run: | set -euo pipefail - git fetch origin "${{ inputs.publish-branch }}:refs/remotes/origin/${{ inputs.publish-branch }}" - git worktree add --detach _publish "origin/${{ inputs.publish-branch }}" + if git ls-remote --exit-code --heads origin "${{ inputs.publish-branch }}" >/dev/null 2>&1; then + git fetch origin "${{ inputs.publish-branch }}:refs/remotes/origin/${{ inputs.publish-branch }}" + git worktree add --detach _publish "origin/${{ inputs.publish-branch }}" + else + echo "Publish branch '${{ inputs.publish-branch }}' doesn't exist yet — bootstrapping it from the released commit." + git worktree add --detach _publish HEAD + fi rsync -a --delete \ --exclude '.git' --exclude '_publish' --exclude '_depctrl' \ --exclude 'ctrf' --exclude 'types' --exclude 'build' \ diff --git a/README.md b/README.md index 92bbc9a..8cf5705 100644 --- a/README.md +++ b/README.md @@ -823,7 +823,7 @@ DependencyControl's own feed URL served from `master` through v0.6.x; from v0.7. ### Using the workflows in your own package -1. **Set up the branches.** Make your dev branch the default and create a publish branch. In your feed, give each package a single dev channel (its name is the `source-channel` input, default `main`); the release workflow creates the published channels. +1. **Set up the branches.** Make your dev branch the default. The first release creates the publish branch for you, so you needn't create it by hand. In your feed, give each package a single dev channel (its name is the `source-channel` input, default `main`); the release workflow creates the published channels. 2. **Add two thin caller workflows** that pin a DependencyControl version and pass your layout. A publish caller (`.github/workflows/release.yml`): ```yaml