diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 107cd5a7..d672ff2a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,7 +6,12 @@ on: workflow_dispatch: inputs: version: - description: Radius version number to use (e.g. 0.1.0, 0.1.0-rc1) + description: Final Radius version number to release (e.g. 0.1.0) + required: true + default: "" + type: string + commit: + description: Full 40-character lowercase SHA of the tested samples commit on edge required: true default: "" type: string @@ -15,14 +20,26 @@ permissions: {} jobs: release-samples: + # Releases are dispatched from edge, which stays the default branch. The release + # branch is published from the tested edge commit, not from the edge tip. + if: github.ref == 'refs/heads/edge' runs-on: ubuntu-24.04 timeout-minutes: 5 permissions: contents: read # required by actions/create-github-app-token steps: + - name: Ensure inputs.commit is a full commit SHA + env: + COMMIT: ${{ inputs.commit }} + run: | + if [[ ! "${COMMIT}" =~ ^[0-9a-f]{40}$ ]]; then + echo "Error: commit must be a full 40-character lowercase commit SHA." + exit 1 + fi + # Generate a short-lived installation token scoped to this repository. # Requires the RADIUS_RELEASE_BOT App installed on radius-project/samples with: - # Contents: Read & Write, Administration: Read & Write + # Contents: Read & Write - name: Get App Token id: app-token uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0 @@ -31,7 +48,6 @@ jobs: private-key: ${{ secrets.RADIUS_RELEASE_BOT_PRIVATE_KEY }} owner: ${{ github.repository_owner }} permission-contents: write - permission-administration: write repositories: samples # Resolve the bot's GitHub-formatted name and email dynamically from the app slug @@ -42,41 +58,44 @@ jobs: with: bot-slug-name: ${{ steps.app-token.outputs.app-slug }} + # Full history includes origin/edge, so the next steps can verify the commit is on edge. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: token: ${{ steps.app-token.outputs.token }} - ref: edge + ref: ${{ inputs.commit }} + fetch-depth: 0 path: samples persist-credentials: false - - name: Ensure inputs.version is valid semver + - name: Ensure inputs.commit is on edge + working-directory: samples + env: + COMMIT: ${{ inputs.commit }} run: | - python ./samples/.github/scripts/validate_semver.py ${{ inputs.version }} + HEAD_SHA="$(git rev-parse HEAD)" + if [[ "${HEAD_SHA}" != "${COMMIT}" ]]; then + echo "Error: checked out ${HEAD_SHA} instead of ${COMMIT}." + exit 1 + fi + if ! git merge-base --is-ancestor "${COMMIT}" origin/edge; then + echo "Error: ${COMMIT} is not reachable from origin/edge." + exit 1 + fi - - name: Parse release channel - id: parse_release_channel + - name: Ensure inputs.version is valid semver + env: + VERSION: ${{ inputs.version }} run: | - # CHANNEL is the major and minor version of the VERSION_NUMBER (e.g. 0.1) - CHANNEL="$(echo ${{ inputs.version }} | cut -d '.' -f 1,2)" - echo "channel=$CHANNEL" >> "${GITHUB_OUTPUT}" + python ./samples/.github/scripts/validate_semver.py "${VERSION}" # The script creates the release commit through the GitHub API with the App token, - # so GitHub signs it and marks it as verified. + # so GitHub signs it and marks it as verified. Its only parent is the checked-out + # commit, and it changes only release configuration. - name: Release samples run: | - ./samples/.github/scripts/release-samples.sh ${{ inputs.version }} + ./samples/.github/scripts/release-samples.sh "${VERSION}" env: + VERSION: ${{ inputs.version }} GH_TOKEN: ${{ steps.app-token.outputs.token }} BOT_NAME: ${{ steps.bot-details.outputs.name }} BOT_EMAIL: ${{ steps.bot-details.outputs.email }} - - - name: Change the default branch - run: | - gh api \ - --method PATCH \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - repos/radius-project/samples \ - -f default_branch='v${{ steps.parse_release_channel.outputs.channel }}' - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} diff --git a/.github/workflows/upmerge.yaml b/.github/workflows/upmerge.yaml deleted file mode 100644 index 508caf90..00000000 --- a/.github/workflows/upmerge.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json -# ------------------------------------------------------------------------------ -# This file is synced from the radius-project/.github repository. -# DO NOT EDIT MANUALLY - changes will be overwritten by the next sync. -# Source: https://github.com/radius-project/.github -# Docs: https://github.com/radius-project/.github/blob/main/eng/SYNC.md#signed-release-upmerge -# ------------------------------------------------------------------------------ ---- -name: Upmerge to edge - -on: - workflow_dispatch: - -permissions: {} - -jobs: - upmerge: - uses: radius-project/.github/.github/workflows/__upmerge.yml@main - permissions: - contents: read - with: - preserve-paths: | - bicepconfig.json - secrets: - RADIUS_RELEASE_BOT_CLIENT_ID: ${{ secrets.RADIUS_RELEASE_BOT_CLIENT_ID }} - RADIUS_RELEASE_BOT_PRIVATE_KEY: ${{ secrets.RADIUS_RELEASE_BOT_PRIVATE_KEY }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6e398bed..4330c90d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,36 +40,25 @@ checkout. When a sample uses `loadTextContent`, `loadFileAsBase64`, `.gitignore` excludes, the validator creates a temporary placeholder and removes it after the build. Missing files that are not git-ignored still fail validation. -## Release branch upmerges - -Run **Upmerge to edge** from the active release branch. -`.github/workflows/upmerge.yaml` is a synced thin caller of the shared -[`__upmerge.yml`](https://github.com/radius-project/.github/blob/main/.github/workflows/__upmerge.yml) -workflow in `radius-project/.github`. Merge preparation, App-backed signing, and -verification are maintained centrally, not copied here. -The caller follows the organization's existing `@main` reusable-workflow pattern. - -The samples caller lists `bicepconfig.json` in its `preserve-paths` input. -See the [shared upmerge guidance](https://github.com/radius-project/.github/blob/main/eng/SYNC.md#signed-release-upmerge) -for signing, preserved-file handling, conflict resolution, no-change behavior, -and required App permissions. - -Update the shared workflow and native caller in `radius-project/.github`. -[`workflow-templates/upmerge-samples.yml`](https://github.com/radius-project/.github/blob/main/workflow-templates/upmerge-samples.yml) -declares the literal `preserve-paths` input for samples. `.github/sync.yml` selects -that static file and its `samples@edge` destination; it does not supply workflow -inputs. Do not edit the synced file or maintain local merge code. -File sync distributes only the caller to `samples@edge`, not release/source -content; it does not replace the three-way upmerge. - -For rollout, merge the central reusable workflow and sync changes **first**, then -merge this caller into the active `v0.61` branch. Syncing only `edge` does not -bootstrap `v0.61`. Review the normal Sync PR delivering the caller to `edge` -before the next release cut; future release branches inherit it from there. -Do not dispatch the caller until the shared workflow exists on `main`. -Already-recorded pre-migration failures still use their old workflow revision. Existing -[PR #2704](https://github.com/radius-project/samples/pull/2704) requires a separately -authorized repair; this rollout does not repair it. +## Branches and releases + +`edge` is the default branch and the target for every PR. Release branches are +never merged back into `edge`; there are no upmerges. + +To fix a supported release, merge the fix to `edge` first. Then backport it in a +separate PR into that release's `vX.Y` branch. + +The Radius release workflow dispatches these sample workflows: + +- **Release candidate:** **Test Samples (K3D)** runs on `edge` with the RC + version. The exact `edge` commit that it tests is the snapshot for that RC. +- **Final release:** **Release samples** runs on `edge` with the final version + and the accepted snapshot commit. It fails unless that commit is on `edge`. + It then publishes `vX.Y` as that commit plus one App-signed commit that + changes only release configuration, such as Bicep extension versions. + `edge` stays the default branch. **Test Samples (K3D)** then runs on `vX.Y`. +- **Patch release:** **Test Samples (K3D)** runs on `vX.Y` with the patch + version. ## Code of Conduct