Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Don't auto-release first preview (even if it's not .0) (#55166)
Conrad Irwin624277748666
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 90c13e820ca..05a28ec9c49 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -718,7 +718,7 @@ jobs:needs:- validate_release_assets- release_compliance_check- if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre')+ if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre')runs-on: namespace-profile-2x4-ubuntu-2404steps:- id: generate-token@@ -727,10 +727,51 @@ jobs:with:app-id: ${{ secrets.ZED_ZIPPY_APP_ID }}private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }}- - name: gh release edit "$GITHUB_REF_NAME" --repo=zed-industries/zed --draft=false- run: gh release edit "$GITHUB_REF_NAME" --repo=zed-industries/zed --draft=false+ - name: steps::checkout_repo+ uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd+ with:+ clean: false+ ref: ${{ github.ref }}+ token: ${{ steps.generate-token.outputs.token }}+ - id: auto-release-preview+ name: release::auto_release_preview::auto_release_preview+ run: |+ tag="$GITHUB_REF_NAME"+ release_published=false++ if [[ ! "$tag" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)-pre$ ]]; then+ echo "::error::expected preview release tag in the form vMAJOR.MINOR.PATCH-pre, got $tag"+ exit 1+ fi++ major="${BASH_REMATCH[1]}"+ minor="${BASH_REMATCH[2]}"+ should_release=true++ released_preview="$(script/get-released-version preview)"+ if [[ -z "$released_preview" || "$released_preview" == "null" ]]; then+ echo "::error::could not determine released preview version"+ exit 1+ fi++ released_preview_major="$(echo "$released_preview" | cut -d. -f1)"+ released_preview_minor="$(echo "$released_preview" | cut -d. -f2)"++ if [[ "$released_preview_major" != "$major" || "$released_preview_minor" != "$minor" ]]; then+ should_release=false+ echo "Leaving $tag as a draft because it is the first preview release for v${major}.${minor}.x"+ fi++ if [[ "$should_release" == "true" ]]; then+ gh release edit "$tag" --repo=zed-industries/zed --draft=false+ release_published=true+ fi++ echo "release_published=$release_published" >> "$GITHUB_OUTPUT"env:GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}+ outputs:+ release_published: ${{ steps.auto-release-preview.outputs.release_published }}push_release_update_notification:needs:- create_draft_release@@ -797,10 +838,10 @@ jobs:echo ""elif [ "$VALIDATE_RESULT" == "failure" ]; thenecho "❌ Release validation failed for $TAG: missing assets: $RUN_URL"- elif [ "$AUTO_RELEASE_RESULT" == "success" ]; then- echo "✅ Release $TAG was auto-released successfully: $RELEASE_URL"elif [ "$AUTO_RELEASE_RESULT" == "failure" ]; thenecho "❌ Auto release failed for $TAG: $RUN_URL"+ elif [ "$AUTO_RELEASE_RESULT" == "success" ] && [ "$AUTO_RELEASE_PUBLISHED" == "true" ]; then+ echo "✅ Release $TAG was auto-released successfully: $RELEASE_URL"elseecho "👀 Release $TAG sitting freshly baked in the oven and waiting to be published: $RELEASE_URL"fi@@ -814,6 +855,7 @@ jobs:VALIDATE_RESULT: ${{ needs.validate_release_assets.result }}COMPLIANCE_RESULT: ${{ needs.release_compliance_check.result }}AUTO_RELEASE_RESULT: ${{ needs.auto_release_preview.result }}+ AUTO_RELEASE_PUBLISHED: ${{ needs.auto_release_preview.outputs.release_published }}RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}TAG: ${{ github.ref_name }}RESULT_RUN_TESTS_MAC: ${{ needs.run_tests_mac.result }}diff --git a/tooling/xtask/src/tasks/workflows/release.rs b/tooling/xtask/src/tasks/workflows/release.rsindex c7db50bf6f6..717bf8786b6 100644--- a/tooling/xtask/src/tasks/workflows/release.rs+++ b/tooling/xtask/src/tasks/workflows/release.rs@@ -64,7 +64,7 @@ pub(crate) fn release() -> Workflow {job_output,);- let auto_release_preview =+ let (auto_release_preview, auto_release_published) =auto_release_preview(&[&validate_release_assets, &release_compliance]);let test_jobs = [@@ -82,6 +82,7 @@ pub(crate) fn release() -> Workflow {&validate_release_assets,&release_compliance,&auto_release_preview,+ &auto_release_published,&test_jobs,&bundle,);@@ -361,23 +362,70 @@ fn release_compliance_check(deps: &[&NamedJob], non_blocking_outcome: JobOutput)named::job(job)}-fn auto_release_preview(deps: &[&NamedJob]) -> NamedJob {+fn auto_release_preview(deps: &[&NamedJob]) -> (NamedJob, JobOutput) {+ fn auto_release_preview(token: &StepOutput) -> Step<Run> {+ named::bash(indoc::indoc! {r#"+ tag="$GITHUB_REF_NAME"+ release_published=false++ if [[ ! "$tag" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)-pre$ ]]; then+ echo "::error::expected preview release tag in the form vMAJOR.MINOR.PATCH-pre, got $tag"+ exit 1+ fi++ major="${BASH_REMATCH[1]}"+ minor="${BASH_REMATCH[2]}"+ should_release=true++ released_preview="$(script/get-released-version preview)"+ if [[ -z "$released_preview" || "$released_preview" == "null" ]]; then+ echo "::error::could not determine released preview version"+ exit 1+ fi++ released_preview_major="$(echo "$released_preview" | cut -d. -f1)"+ released_preview_minor="$(echo "$released_preview" | cut -d. -f2)"++ if [[ "$released_preview_major" != "$major" || "$released_preview_minor" != "$minor" ]]; then+ should_release=false+ echo "Leaving $tag as a draft because it is the first preview release for v${major}.${minor}.x"+ fi++ if [[ "$should_release" == "true" ]]; then+ gh release edit "$tag" --repo=zed-industries/zed --draft=false+ release_published=true+ fi++ echo "release_published=$release_published" >> "$GITHUB_OUTPUT"+ "#})+ .id("auto-release-preview")+ .add_env(("GITHUB_TOKEN", token))+ }+let (authenticate, token) = steps::authenticate_as_zippy().into();+ let auto_release_preview_step = auto_release_preview(&token);+ let release_published = StepOutput::new(&auto_release_preview_step, "release_published");- named::job(+ let job = named::job(dependant_job(deps).runs_on(runners::LINUX_SMALL).cond(Expression::new(indoc::indoc!(- r#"startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre')"#+ r#"startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre')"#))).add_step(authenticate).add_step(- steps::script(- r#"gh release edit "$GITHUB_REF_NAME" --repo=zed-industries/zed --draft=false"#,- )- .add_env(("GITHUB_TOKEN", &token)),+ steps::checkout_repo()+ .with_token(&token)+ .with_ref(Context::github().ref_()),)- )+ .add_step(auto_release_preview_step)+ .outputs([(+ release_published.name.to_owned(),+ release_published.to_string(),+ )]),+ );+ let release_published = release_published.as_job_output(&job);+ (job, release_published)}pub(crate) fn download_workflow_artifacts() -> Step<Use> {@@ -453,6 +501,7 @@ pub(crate) fn push_release_update_notification(validate_assets_job: &NamedJob,compliance_job: &NamedJob,auto_release_preview: &NamedJob,+ auto_release_published: &JobOutput,test_jobs: &[&NamedJob],bundle_jobs: &ReleaseBundleJobs,) -> NamedJob {@@ -487,6 +536,10 @@ pub(crate) fn push_release_update_notification("AUTO_RELEASE_RESULT".into(),format!("${{{{ needs.{}.result }}}}", auto_release_preview.name),),+ (+ "AUTO_RELEASE_PUBLISHED".into(),+ auto_release_published.to_string(),+ ),("RUN_URL".into(), CURRENT_ACTION_RUN_URL.to_string()),("TAG".into(), Context::github().ref_name().to_string()),]@@ -537,10 +590,10 @@ pub(crate) fn push_release_update_notification(echo ""elif [ "$VALIDATE_RESULT" == "failure" ]; thenecho "❌ Release validation failed for $TAG: missing assets: $RUN_URL"- elif [ "$AUTO_RELEASE_RESULT" == "success" ]; then- echo "✅ Release $TAG was auto-released successfully: $RELEASE_URL"elif [ "$AUTO_RELEASE_RESULT" == "failure" ]; thenecho "❌ Auto release failed for $TAG: $RUN_URL"+ elif [ "$AUTO_RELEASE_RESULT" == "success" ] && [ "$AUTO_RELEASE_PUBLISHED" == "true" ]; then+ echo "✅ Release $TAG was auto-released successfully: $RELEASE_URL"elseecho "👀 Release $TAG sitting freshly baked in the oven and waiting to be published: $RELEASE_URL"fi