From 9267b71ce2652691939e898ee14b29098229b620 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 11 Dec 2024 08:46:42 +0100 Subject: [PATCH 01/21] WIP --- .github/workflows/cabal-build-all.yml | 2 +- .github/workflows/plutus-release.yml | 60 +++++++++++++++++++++++++++ scripts/prepare-bins.sh | 33 ++++----------- scripts/s3-sync-unzip.sh | 35 ---------------- 4 files changed, 69 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/plutus-release.yml delete mode 100755 scripts/s3-sync-unzip.sh diff --git a/.github/workflows/cabal-build-all.yml b/.github/workflows/cabal-build-all.yml index 6de3bed6690..337cbd82bc8 100644 --- a/.github/workflows/cabal-build-all.yml +++ b/.github/workflows/cabal-build-all.yml @@ -24,7 +24,7 @@ jobs: - name: Checkout uses: actions/checkout@main - - name: Cold Build On ${{ matrix.ghc }} + - name: Cold Build / ${{ matrix.ghc }} / x86_64-linux run: | nix develop --no-warn-dirty --accept-flake-config .#${{ matrix.ghc }} \ --command bash -c 'cabal clean && cabal update && cabal build all' \ No newline at end of file diff --git a/.github/workflows/plutus-release.yml b/.github/workflows/plutus-release.yml new file mode 100644 index 00000000000..729da62794f --- /dev/null +++ b/.github/workflows/plutus-release.yml @@ -0,0 +1,60 @@ +# This workflow handles the release process. + +name: "🛸 Plutus Release" + +on: + workflow_dispatch: + inputs: + version: + description: | + The new version number, e.g. 1.40.0.0 + required: true + type: string + + pull_request_target: + types: + - closed + branches: + - 'release/**' + +jobs: + step-1: + name: Step 1 + runs-on: [self-hosted, plutus-ci] + if: github.event_name == 'workflow_dispatch' + steps: + - name: Checkout + uses: actions/checkout@main + + - name: Build Site + run: | + # nix develop --no-warn-dirty --accept-flake-config --command <<< + git checkout master + git pull --rebase origin master + git checkout -b release/${{ inputs.version }} + ./scripts/check-broken-links.sh ${{ inputs.version }} + git add . + git commit -m "Release ${{ inputs.version }}" + git push + gh pr create --title "Release ${{ inputs.version }}" --label "No Changelog Required" + + step-2: + name: Step 2 + runs-on: [self-hosted, plutus-ci] + if: github.event_name == 'pull_request_target' + steps: + - name: Checkout + uses: actions/checkout@main + + - name: Create Draft Release + run: | + # nix develop --no-warn-dirty --accept-flake-config --command <<< + + bash ./scripts/prepare-bin.sh + + tag="${${{ github.ref_name }}#release/}" + + gh release create $tag --title "$tag" --generate-notes --latest + gh release upload $tag pir-x86_64-linux-ghc96 uplc-x86_64-linux-ghc96 --clobber + + diff --git a/scripts/prepare-bins.sh b/scripts/prepare-bins.sh index eaa9e20bda9..c4af39eed71 100755 --- a/scripts/prepare-bins.sh +++ b/scripts/prepare-bins.sh @@ -2,28 +2,11 @@ set -euo pipefail -banner='\n -Lets prepare binaries for a release:\n - 1. Build `pir`\n - 2. Compress `pir` with `upx`\n - 3. Build `uplc`\n - 4. Compress `uplc` with `upx`\n -' - -echo -e $banner - -echo "Building pir..." - -nix build ".#hydraJobs.x86_64-linux.musl64.ghc96.pir" - -echo "Compressing pir..." - -upx -9 ./result/bin/pir -o pir-x86_64-linux-ghc96 --force-overwrite - -echo "Building uplc..." - -nix build ".#hydraJobs.x86_64-linux.musl64.ghc96.uplc" - -echo "Compressing uplc..." - -upx -9 ./result/bin/uplc -o uplc-x86_64-linux-ghc96 --force-overwrite +echo -e "Preparing static binaries for release..." + +for exec in "uplc pir plc"; do + echo "Building $exec..." + nix build ".#hydraJobs.x86_64-linux.musl64.ghc96.$exec" + echo "Compressing $exec..." + upx -9 ./result/bin/$exec -o "$exec-x86_64-linux-ghc96" --force-overwrite +done \ No newline at end of file diff --git a/scripts/s3-sync-unzip.sh b/scripts/s3-sync-unzip.sh deleted file mode 100755 index 633e36fe33b..00000000000 --- a/scripts/s3-sync-unzip.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -# Sync an S3 prefix to a local directory, and unzip the bz2 files -# Example usage: -# LOCAL_DIR=/tmp/script-dump/ \ -# AWS_ACCESS_KEY_ID=<...> \ -# AWS_SECRET_ACCESS_KEY=<...> \ -# AWS_DEFAULT_REGION=<...> \ -# AWS_ENDPOINT_URL=https://s3.devx.iog.io \ -# ./scripts/s3-sync-unzip.sh \ -# s3://plutus/mainnet-script-dump/ \ -# \*.event.bz2 - -set -euo pipefail - -# Only download S3 objects whose keys start with this -S3_PREFIX=$1 -# Only download S3 objects whose keys end with this -S3_SUFFIX=${2:-"*"} - -mkdir -p "$LOCAL_DIR" - -set -x -aws --endpoint-url "$AWS_ENDPOINT_URL" s3 sync "$S3_PREFIX" "$LOCAL_DIR" --exclude "*" --include "$S3_SUFFIX" -{ set +x; } 2>/dev/null - -for zipped in "$LOCAL_DIR"/*.bz2 -do - if ! [ -f "${zipped%".bz2"}" ]; then - set -x - bunzip2 -k "$zipped" - rm "$zipped" - { set +x; } 2>/dev/null - fi -done From 77deb0d6c66ae6db062a77b0ddb80676eb6404b7 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 12 Dec 2024 13:40:36 +0100 Subject: [PATCH 02/21] Automated Release --- .github/workflows/broken-links.yml | 5 +- .github/workflows/cabal-build-all.yml | 6 +- .../workflows/cardano-constitution-tests.yml | 7 +- .github/workflows/changelog-label.yml | 5 +- .github/workflows/cost-model-benchmark.yml | 10 +- .github/workflows/docusaurus-site.yml | 9 +- .github/workflows/haddock-site.yml | 20 ++- .github/workflows/longitudinal-benchmark.yml | 15 +- .github/workflows/manual-benchmark.yml | 9 +- .github/workflows/metatheory-site.yml | 12 ++ .github/workflows/nightly-testsuite.yml | 9 +- .github/workflows/papers-and-specs.yml | 6 +- .github/workflows/plutus-release.yml | 60 -------- .github/workflows/plutus-tx-template.yml | 16 +- .github/workflows/slack-message-broker.yml | 4 +- .github/workflows/sprint-issues-rollover.yml | 2 +- RELEASE.adoc | 89 +---------- scripts/assemble-changelog.sh | 19 --- scripts/prepare-bins.sh | 12 -- scripts/prepare-release.sh | 44 ------ scripts/publish-release.sh | 138 ++++++++++++++++++ scripts/update-version.sh | 60 -------- 22 files changed, 236 insertions(+), 321 deletions(-) delete mode 100644 .github/workflows/plutus-release.yml delete mode 100755 scripts/assemble-changelog.sh delete mode 100755 scripts/prepare-bins.sh delete mode 100755 scripts/prepare-release.sh create mode 100644 scripts/publish-release.sh delete mode 100755 scripts/update-version.sh diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml index f149e0615a3..f7b67064e06 100644 --- a/.github/workflows/broken-links.yml +++ b/.github/workflows/broken-links.yml @@ -1,9 +1,12 @@ # This job checks for broken links in various files in the repo. +# +# This job runs on all pull requests and on push to master, and it can also be triggered manually. + name: "🔗 Broken Links" on: - workflow_dispatch: # Or manually dispatch the job + workflow_dispatch: pull_request: push: branches: diff --git a/.github/workflows/cabal-build-all.yml b/.github/workflows/cabal-build-all.yml index 337cbd82bc8..2cbc382bdfc 100644 --- a/.github/workflows/cabal-build-all.yml +++ b/.github/workflows/cabal-build-all.yml @@ -1,13 +1,17 @@ -# This workflow runs `cabal build all` on Linux with all supported GHC versions. +# This job runs `cabal build all` on Linux with all supported GHC versions. # Normally, if Nix can build the shell and the packages via haskell.nix, we can be confident that # Cabal can build the project inside the Nix shell. # However, this workflow is implemented to catch edge cases, such as the one described in # https://github.com/IntersectMBO/plutus/issues/6625. +# +# This job runs on all pull requests and on push to master, and it can also be triggered manually. + name: "👷 Cabal Build All" on: workflow_dispatch: + pull_request: push: branches: - master diff --git a/.github/workflows/cardano-constitution-tests.yml b/.github/workflows/cardano-constitution-tests.yml index f7eb4f2b8b0..607c4973f5c 100644 --- a/.github/workflows/cardano-constitution-tests.yml +++ b/.github/workflows/cardano-constitution-tests.yml @@ -1,11 +1,14 @@ -# This workflow runs the nighlty cardano-constitution tests +# This job runs the nightly cardano-constitution tests. +# +# This job runs daily at 2am, and it can also be triggered manually. + name: "🗽 Cardano Constitution Tests" on: workflow_dispatch: schedule: - - cron: 0 2 * * * # Daily at 2am + - cron: 0 2 * * * jobs: run: diff --git a/.github/workflows/changelog-label.yml b/.github/workflows/changelog-label.yml index 42d93020ac9..36ed8f3c56b 100644 --- a/.github/workflows/changelog-label.yml +++ b/.github/workflows/changelog-label.yml @@ -1,6 +1,9 @@ # This job enforces that: either some changelog.d/** files were added by the # PR, or the PR has the "No Changelog Required" label. - +# +# This job runs on all pull requests, and on pull request label changes. + + name: "🏷️ Changelog Label" on: diff --git a/.github/workflows/cost-model-benchmark.yml b/.github/workflows/cost-model-benchmark.yml index 7f15a75852f..e6db1671e4a 100644 --- a/.github/workflows/cost-model-benchmark.yml +++ b/.github/workflows/cost-model-benchmark.yml @@ -1,12 +1,14 @@ -# This workflow runs the cost model benchmark and uploads the results as a -# GitHub artifact. +# This job runs the cost model benchmark and uploads the results as a GitHub artifact. +# +# This job must be triggered manually via workflow dispatch. + name: "💰 Cost Model Benchmark" on: workflow_dispatch: inputs: - entra-bench-args: + extra-bench-args: description: 'extra argument(s) to pass to the cost-model-budgeting-bench command' default: '' type: string @@ -21,7 +23,7 @@ jobs: uses: actions/checkout@main - name: Run Benchmark - run: nix --accept-flake-config run .#cost-model-budgeting-bench -- --csv results.csv ${{ inputs.entra-bench-args }} + run: nix --accept-flake-config run .#cost-model-budgeting-bench -- --csv results.csv ${{ inputs.extra-bench-args }} - name: Upload Results uses: actions/upload-artifact@main diff --git a/.github/workflows/docusaurus-site.yml b/.github/workflows/docusaurus-site.yml index 3ff535e5679..036f7a2e58d 100644 --- a/.github/workflows/docusaurus-site.yml +++ b/.github/workflows/docusaurus-site.yml @@ -1,7 +1,10 @@ -# This workflow builds the Docusaurus site on pull_request. -# It also publishes the site on push to master to: +# This job builds and deploys the Docusaurus site. +# +# This job builds the site on pull requests, and it also automatically deploys +# the site on push to master or on workflow dispatch to: # https://plutus.cardano.intersectmbo.org/docs + name: "🦕 Docusaurus Site" on: @@ -28,7 +31,7 @@ jobs: run: nix develop --no-warn-dirty --accept-flake-config --command bash -c 'yarn && yarn build' - name: Deploy Site - if: github.event_name == 'push' + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' uses: JamesIves/github-pages-deploy-action@v4.7.2 with: folder: doc/docusaurus/build diff --git a/.github/workflows/haddock-site.yml b/.github/workflows/haddock-site.yml index ba58e93cc03..e21cb44eb89 100644 --- a/.github/workflows/haddock-site.yml +++ b/.github/workflows/haddock-site.yml @@ -1,9 +1,17 @@ -# This workflow builds and publishes the Haddock site to: -# https://plutus.cardano.intersectmbo.org/haddock/$version -# And optionally to: +# This job builds and deploys the Haddock site. +# +# When this job is triggered manually via workflow dispatch, it builds and then +# publishes the site according to the 'ref' input: +# https://plutus.cardano.intersectmbo.org/haddock/$ref +# And optionally (if the 'latest' flag is set) to: # https://plutus.cardano.intersectmbo.org/haddock/latest -# On push to master, this workflows publishes to: +# +# This job also builds and publishes the site on push to master to: # https://plutus.cardano.intersectmbo.org/haddock/master +# +# This job does not trigger on each pull request because it takes about 1h to run. +# However it will build (but not deploy) the site on pull requests to the release/* branches. + name: "📜 Haddock Site" @@ -11,6 +19,9 @@ on: push: branches: - master + pull_request: + branches: + - 'release/*' workflow_dispatch: inputs: @@ -72,6 +83,7 @@ jobs: - name: Deploy Site uses: JamesIves/github-pages-deploy-action@v4.7.2 + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' with: folder: _haddock target-folder: haddock/${{ inputs.destination || github.ref_name }} diff --git a/.github/workflows/longitudinal-benchmark.yml b/.github/workflows/longitudinal-benchmark.yml index a86f3b7d020..076c013025b 100644 --- a/.github/workflows/longitudinal-benchmark.yml +++ b/.github/workflows/longitudinal-benchmark.yml @@ -1,18 +1,21 @@ -# This workflow runs the benchmarks defined in the environment variable BENCHMARKS. -# It will collect and aggreate the benchmark output, format it and feed it to the -# github-action-benchmark action. -# +# This job runs a suite of benchmarks and detects performance regressions. # The benchmark charts are live at https://plutus.cardano.intersectmbo.org/dev/bench # The benchmark data is available at https://plutus.cardano.intersectmbo.org/dev/bench/data.js # -# This is a performance regression check that is run on every push master. +# This job runs on push to master, and on pull requests to the release/* branches, +# and it can also be triggered manually. + name: "🩺 Longitudinal Benchmark" on: + workflow_dispatch: push: branches: - master + pull_request: + branches: + - 'release/*' permissions: # Deployments permission to deploy GitHub pages website @@ -34,7 +37,7 @@ jobs: run: nix develop --no-warn-dirty --accept-flake-config --command bash ./scripts/run-longitudinal-benchmarks.sh # We need this otherwise the next step will fail with: - # `pre-commit` not found. Did you forget to activate your virtualenv? + # `pre-commit` not found. Did you forget to activate your virtualenv? # This is because github-action-benchmark will call git commit outside nix develop. - name: Disable Git Hooks run: git config core.hooksPath no-hooks diff --git a/.github/workflows/manual-benchmark.yml b/.github/workflows/manual-benchmark.yml index 3d808944d17..8574e2a979c 100644 --- a/.github/workflows/manual-benchmark.yml +++ b/.github/workflows/manual-benchmark.yml @@ -1,8 +1,11 @@ -# This workflows checks for comments in PRs. If the comment has this format: -# /benchmark NAME -# Then this action will run the benchmark with the given NAME, first against +# This job runs the desired benchmarks on demand. +# +# This job triggers whenever a comment is created in any PR. +# If the comment has this format: "/benchmark NAME" +# The this job will run the benchmark with the given NAME, first against # the current branch and then comparing the results against the master branch. + name: "🚀 Manual Benchmark" on: diff --git a/.github/workflows/metatheory-site.yml b/.github/workflows/metatheory-site.yml index 54ab5f3b1ed..ec2e00e8636 100644 --- a/.github/workflows/metatheory-site.yml +++ b/.github/workflows/metatheory-site.yml @@ -5,6 +5,18 @@ # On push to master, this workflows publishes to: # https://plutus.cardano.intersectmbo.org/metatheory/master +# This job builds and deploys the Metatheory site. +# +# When this job is triggered manually via workflow dispatch, it builds and then +# publishes the site according to the 'ref' input: +# https://plutus.cardano.intersectmbo.org/metatheory/$version +# And optionally (if the 'latest' flag is set) to: +# https://plutus.cardano.intersectmbo.org/metatheory/latest +# +# This job also builds and publishes the site on push to master to: +# https://plutus.cardano.intersectmbo.org/metatheory/master + + name: "🔮 Metatheory Site" on: diff --git a/.github/workflows/nightly-testsuite.yml b/.github/workflows/nightly-testsuite.yml index 429485de4c3..d1ff0944ccc 100644 --- a/.github/workflows/nightly-testsuite.yml +++ b/.github/workflows/nightly-testsuite.yml @@ -1,15 +1,18 @@ -# This workflow runs the nightly plutus-core-test and plutus-ir-test test suite. +# This job runs the nightly plutus-core-test and plutus-ir-test test suite. +# +# This job runs daily at midnight, and it can also be triggered manually. + name: "🌘 Nightly Testsuite" on: schedule: - - cron: 0 0 * * * # Daily at midnight + - cron: 0 0 * * * workflow_dispatch: inputs: hedgehog-tests: - description: Numer of tests to run (--hedgehog-tests XXXXX) + description: Number of tests to run (--hedgehog-tests XXXXX) required: false default: "100000" diff --git a/.github/workflows/papers-and-specs.yml b/.github/workflows/papers-and-specs.yml index 0a85fca986a..3a4c5aa7cdd 100644 --- a/.github/workflows/papers-and-specs.yml +++ b/.github/workflows/papers-and-specs.yml @@ -1,5 +1,7 @@ -# This job builds various papers and deploys them to: -# https://plutus.cardano.intersectmbo.org/resources +# This job builds and deploys various papers. +# +# This job runs on all push to master and can also be triggered manually. +# It deploys the artifacts to: https://plutus.cardano.intersectmbo.org/resources name: "📝 Papers & Specs" diff --git a/.github/workflows/plutus-release.yml b/.github/workflows/plutus-release.yml deleted file mode 100644 index 729da62794f..00000000000 --- a/.github/workflows/plutus-release.yml +++ /dev/null @@ -1,60 +0,0 @@ -# This workflow handles the release process. - -name: "🛸 Plutus Release" - -on: - workflow_dispatch: - inputs: - version: - description: | - The new version number, e.g. 1.40.0.0 - required: true - type: string - - pull_request_target: - types: - - closed - branches: - - 'release/**' - -jobs: - step-1: - name: Step 1 - runs-on: [self-hosted, plutus-ci] - if: github.event_name == 'workflow_dispatch' - steps: - - name: Checkout - uses: actions/checkout@main - - - name: Build Site - run: | - # nix develop --no-warn-dirty --accept-flake-config --command <<< - git checkout master - git pull --rebase origin master - git checkout -b release/${{ inputs.version }} - ./scripts/check-broken-links.sh ${{ inputs.version }} - git add . - git commit -m "Release ${{ inputs.version }}" - git push - gh pr create --title "Release ${{ inputs.version }}" --label "No Changelog Required" - - step-2: - name: Step 2 - runs-on: [self-hosted, plutus-ci] - if: github.event_name == 'pull_request_target' - steps: - - name: Checkout - uses: actions/checkout@main - - - name: Create Draft Release - run: | - # nix develop --no-warn-dirty --accept-flake-config --command <<< - - bash ./scripts/prepare-bin.sh - - tag="${${{ github.ref_name }}#release/}" - - gh release create $tag --title "$tag" --generate-notes --latest - gh release upload $tag pir-x86_64-linux-ghc96 uplc-x86_64-linux-ghc96 --clobber - - diff --git a/.github/workflows/plutus-tx-template.yml b/.github/workflows/plutus-tx-template.yml index 302a55ddc1f..ac52d22648e 100644 --- a/.github/workflows/plutus-tx-template.yml +++ b/.github/workflows/plutus-tx-template.yml @@ -1,9 +1,13 @@ -# This workflows ensures that the plutus-tx-template repository stays working -# even if there are changes in plutus. It checks out both the current commit of -# plutus and the master branch of plutus-tx-template. Then, it creates a -# cabal.project.local for plutus-tx-template that adjusts the plutus version. -# Finally, it double-checks that everything still builds correctly using cabal -# inside the devx shell. +# This job builds the plutus-tx-template using the current version of the plutus code. +# +# It ensures that the plutus-tx-template repository stays working even if there +# are changes in plutus. It checks out both the current commit of plutus and the +# master branch of plutus-tx-template. Then, it creates a cabal.project.local for +# plutus-tx-template that adjusts the plutus version. Finally, it double-checks +# that everything still builds correctly using cabal inside the devx shell. +# +# This job runs on all pull requests. + name: "🏛️ PlutusTx Template" diff --git a/.github/workflows/slack-message-broker.yml b/.github/workflows/slack-message-broker.yml index c5dbef45a3b..617283cb14e 100644 --- a/.github/workflows/slack-message-broker.yml +++ b/.github/workflows/slack-message-broker.yml @@ -1,5 +1,7 @@ -# This workflow sends a message to the plutus-ci channel whenever a status check fails, +# This job sends a message to the plutus-ci channel whenever a status check fails, # and tried to notify the author of the commit that caused the failure. +# +# This job triggers whenever a workflow run or a check run is completed. name: "📮 Slack Message Broker" diff --git a/.github/workflows/sprint-issues-rollover.yml b/.github/workflows/sprint-issues-rollover.yml index 7e7971e252d..49b442dcc83 100644 --- a/.github/workflows/sprint-issues-rollover.yml +++ b/.github/workflows/sprint-issues-rollover.yml @@ -1,4 +1,4 @@ -# This workflows moves issues and pull requests to the next sprint iteration of +# This job moves issues and pull requests to the next sprint iteration of # the Plutus Backlog project. In practice, all open backlog items in the Current # Iteration (the one that is still in progress) will be moved to the Next # Iteration (the one that will start next). diff --git a/RELEASE.adoc b/RELEASE.adoc index 15f34e05f56..25a8f2a654f 100644 --- a/RELEASE.adoc +++ b/RELEASE.adoc @@ -31,20 +31,6 @@ A minor release is also allowed to change the observable behaviors of functions For example, if a function returns a list of things and makes no promise on the order of elements in the returned list, then a minor release may change the order. - A patch release (e.g., 3.5.2.1 -> 3.5.2.2) can only contain such things as simple bug fixes, performance improvements, and documentation updates. -=== Version Qualifiers - -Version qualifiers, also known as pre-release versions, usually refer to alpha, beta, and release candidate. -Typically, alpha and beta are pre-feature complete, while release candidates are post-feature complete. - -We do not tag or publish alpha or beta versions for libraries. -Depending on an alpha or beta version of a library requires `source-repository-package`, which is quite inconvenient. -It is also uncommon for a library to publish pre-release versions (unless it is new or a complete rewrite). - -We do tag release candidates, e.g., 3.5.2.1-rc1, because additional non-CI tests and checks may need to be carried out (see "Release QA Process"). -Tagging release candidates makes it easy to identify the correct commit to run these tests and checks against. - -For executables, we may publish alpha, beta or release candidates at our discretion. - == Release Frequency We will begin by making a new major or minor release every 4 weeks, and evaluate and adjust the frequency in the future. @@ -55,80 +41,7 @@ In all other cases, we always start a new major or minor release from master. == Release Process -=== Major and Minor Releases - -Suppose we are releasing version `x.y.z.0`. - -1. Tag `x.y.z.0-rc1` on master. -- There's no need to create a release branch at this point. -A release branch is only needed if bugs are found in `x.y.z.0-rc1` and we need to backport a fix from master. -- This step can be omitted if no additional tests and checks are needed in the release QA process. See "Release QA Process" below. -2. In future it will be necessary to run the release QA process (see "Release QA Process" below) at this point, however currently it is not required for the lack of specific instructions. -3. If no release blocking issue is found, run `./scripts/prepare-release.sh x.y.z.0 `. -This updates versions and version bounds, and assembles the changelogs.open a PR for updating the cabal files and the changelog files. -- `` should normally be empty, which will prepare the default packages, or can be an explicit list of packages to prepare. -4. Review the changelogs and edit manually if needed. -5. Open a PR for updating the cabal files and the changelog files. Example: https://github.com/IntersectMBO/plutus/pull/5452. -6. Once the PR is merged, 'Draft a new Release' with name `x.y.z.0` using https://github.com/IntersectMBO/plutus/releases/new[Github's release interface] (this can also be found under `Tags`/`Releases` on the main `plutus` page): -- Choose as git tag `x.y.z.0` -- Choose as target the git commit hash which points to the release commit -- Click `Generate release notes` to automatically fill in the details of what's changed -- Create and attach pir&uplc executables to the release by running the following script inside the repository where its HEAD is at the release commit: `./scripts/prepare-bins.sh`. This will create `pir-x86_64-linux-ghc96` and `uplc-x86_64-linux-ghc96` executables, compress them and put in the project's root folder. Upload them to the release draft. -- Click `Publish release`. -7. Open a PR in the https://github.com/IntersectMBO/cardano-haskell-packages[CHaP repository] for publishing the new version. + -If you are making PR from your own fork then don't forget to sync your fork with the upstream first. + -Run `./scripts/add-from-github.sh "https://github.com/IntersectMBO/plutus" COMMIT-SHA plutus-core plutus-ledger-api plutus-tx plutus-tx-plugin` (see https://github.com/IntersectMBO/cardano-haskell-packages#-from-github[the README on CHaP]). Example: https://github.com/IntersectMBO/cardano-haskell-packages/pull/764. -- If issues are found, create a release branch `release/x.y.z`, fix the issues on master, backport the fixes to `release/x.y.z`, tag `x.y.z.0-rc2`, and go to step 4. -- Why not just fix the issues on master and tag `x.y.z.0-rc2` from master? -It is desirable to minimize the amount of change between `rc1` and `rc2`, because it may reduce the tests and checks that need to be performed against `rc2`. -For instance, if `plutus-ledger-api` is the only package changed, there is no need to re-run tests on `plutus-core` or `plutus-tx`. -Another example is if a security audit is done on `rc1`, and the changes in `rc2` do not modify the audited code, then the audit does not need to be re-done. -- If another CHaP PR gets merged before yours it will invalidate the timestamps and you won't be able to merge: see the https://github.com/IntersectMBO/cardano-haskell-packages/blob/main/README.md[CHaP README file], in particular https://github.com/IntersectMBO/cardano-haskell-packages/blob/main/README.md#monotonically-increasing-timestamps[this section]. Read https://github.com/IntersectMBO/cardano-haskell-packages/blob/main/README.md#dealing-with-timestamp-conflicts[this section] for advice on how to deal with this problem. - -8. Make a PR to update the version used in `plutus-tx-template` -- Navigate to the https://github.com/IntersectMBO/plutus-tx-template/actions/workflows/bump-plutus-version.yml[Bump Plutus Version Action] on GitHub -- Click the `Run workflow` button on the right, enter the new release version and confirm -- This will automatically open a PR in `plutus-tx-template` with auto-merge enabled -- Ensure that CI is green and the PR gets merged - -9. Publish the updated Metatheory site -- Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/metatheory-site.yml[Metatheory Site Action] on GitHub -- Click the `Run workflow` button on the right, enter the new release version 2 times, leave the checkbox Enabled, and confirm -- Ensure that the action completes successfully - -10. Publish the updated Haddock site -- Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/haddock-site.yml[Haddock Site Action] on GitHub -- Click the `Run workflow` button on the right, enter the new release version 2 times, leave the checkbox Enabled, and confirm -- Ensure that the action completes successfully - -11. Delete unused branches and tags -- If it was created, delete the `release/*` branch locally and on GitHub -- If they were created, delete any release candidate `-rc*` tags locally and on GitHub - -=== Patch Releases - -Suppose we are releasing version `x.y.z.w`. - -1. If it is the first time we are making a patch release for version `x.y.z` (i.e., `x.y.z.0` -> `x.y.z.1`), a release branch may not exist for `x.y`. -If so, create branch `release/x.y.z` from the `x.y.z.0` tag. -- We create release branches lazily, because we do not expect to make many patch releases. -2. Backport the needed fixes from master to `release/x.y.z`. -3. Tag `x.y.z.w-rc1` on the release branch. -- This step can be omitted if no additional tests and checks are needed in the release QA process. See "Release QA Process" below. -4. Run the release QA process. See "Release QA Process" below. -5. If no release blocking issue is found, run `./scripts/prepare-release.sh x.y.z.w `. -6. Open a PR for updating the cabal files and the changelog files. -7. Once the PR is merged, tag the commit `x.y.z.w`, and open a PR in the CHaP repository for publishing the new version. -- If issues are found, fix them on master, backport the fixes to `release/x.y.z`, and go to step 5. -8. If it was created, delete the `release/*` branch locally and on GitHub - -=== Release QA Process - -All applicable tests and checks that haven't been run on the release candidate should be carried out prior to tagging and publishing a release. -- This includes all tests that can be done with only the Plutus repo, such as unit tests, property-based tests, conformance tests and nightly tests. -- In some cases we need input from domain experts and/or security audit (e.g., when adding a cryptography builtin). -The right group of people should be involved and sign off on the tests and checks. -- This does not include tests that require building a new node, or integrating with other downstream projects. +Run `./scripts/prepare-release.sh` to manage the release process. == Backwards Compatibility with Cardano API diff --git a/scripts/assemble-changelog.sh b/scripts/assemble-changelog.sh deleted file mode 100755 index 64dc63747f0..00000000000 --- a/scripts/assemble-changelog.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -usage () { - echo "$(basename $0) PACKAGE VERSION - Assembles the changelog for PACKAGE at VERSION." -} - -if [ "$#" == "0" ]; then - usage - exit 1 -fi - -PACKAGE=$1 -VERSION=$2 - -echo "Assembling changelog for $PACKAGE-$VERSION" -pushd $PACKAGE > /dev/null -scriv collect --version "$VERSION" -popd > /dev/null diff --git a/scripts/prepare-bins.sh b/scripts/prepare-bins.sh deleted file mode 100755 index c4af39eed71..00000000000 --- a/scripts/prepare-bins.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -echo -e "Preparing static binaries for release..." - -for exec in "uplc pir plc"; do - echo "Building $exec..." - nix build ".#hydraJobs.x86_64-linux.musl64.ghc96.$exec" - echo "Compressing $exec..." - upx -9 ./result/bin/$exec -o "$exec-x86_64-linux-ghc96" --force-overwrite -done \ No newline at end of file diff --git a/scripts/prepare-release.sh b/scripts/prepare-release.sh deleted file mode 100755 index 3055a9c09da..00000000000 --- a/scripts/prepare-release.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -usage () { - echo "$(basename $0) VERSION [PACKAGE...] - Prepares to release PACKAGEs at VERSION. If no PACKAGEs are provided, - prepares to release the default packages." -} - -if [ "$#" == "0" ]; then - usage - exit 1 -fi - -set -euo pipefail - -VERSION=$1 - -shift - -default_packages=( - "plutus-core" - "plutus-ledger-api" - "plutus-tx" - "plutus-tx-plugin" -) - -release_packages=( "$@" ) - -if [ ${#release_packages[@]} -eq 0 ]; then - release_packages+=( "${default_packages[@]}" ) -fi - -echo "Preparing release for ${release_packages[*]}" -echo "" -echo "Updating versions ..." -for package in "${release_packages[@]}"; do - $(dirname $0)/update-version.sh "$package" "$VERSION" -done - -echo "" -echo "Assembling changelogs ..." -for package in "${release_packages[@]}"; do - $(dirname $0)/assemble-changelog.sh "$package" "$VERSION" -done diff --git a/scripts/publish-release.sh b/scripts/publish-release.sh new file mode 100644 index 00000000000..1cbe978bf93 --- /dev/null +++ b/scripts/publish-release.sh @@ -0,0 +1,138 @@ +set -euox pipefail + + +VERSION="$1" + + +log() { + echo "*** RELEASE *** $1" +} + + +main() { + if [ "$(git rev-parse --abbrev-ref HEAD)" != "$VERSION" ]; then + log "No tag $VERSION found, creating a new release PR" + create-release-pr + else + log "Tag $VERSION found, publishing the release" + publish-release + fi +} + + +create-release-pr() { + if ! git diff --quiet && git diff --cached --quiet; then + log "Uncommitted changes detected in your branch, please commit or stash them before running this script." + exit 1 + fi + + if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + log "Invalid version $VERSION, expected format like 1.42.0.0" + exit 1 + fi + + local MAJOR_VERSION="${VERSION%%.*}.${VERSION#*.}"; MAJOR_VERSION="${MAJOR_VERSION%%.*}" + + log "Creating release branch release/$VERSION" + git checkout master + git pull --rebase origin master + git checkout -b release/$VERSION + + local RELEASE_PACKAGES=( + "plutus-core" + "plutus-ledger-api" + "plutus-tx" + "plutus-tx-plugin" + ) + + for PACKAGE in "${RELEASE_PACKAGES[@]}"; do + log "Updating ./$PACKAGE/$PACKAGE.cabal to ==$VERSION and ^>=$MAJOR_VERSION" + find . -name "?*.cabal" \ + -exec sed -i "s/\(^version:\s*\).*/\1$VERSION/" "./$PACKAGE/$PACKAGE.cabal" \; \ + -exec sed -i "s/\(^[ \t]*,[ \t]*$PACKAGE[^-A-Za-z0-1][^^]*\).*/\1^>=$MAJOR_VERSION/" {} \; \ + -exec sed -i "s/\(^[ \t]*,[ \t]*$PACKAGE$\)/\1 ^>=$MAJOR_VERSION/" {} \; + + log "Assembling changelog for $PACKAGE" + pushd $PACKAGE > /dev/null + scriv collect --version "$VERSION" + popd > /dev/null + done + + log "Committing changes and creating PR on GitHub" + git add . + git commit -m "Release $VERSION" + git push + gh pr create --title "Release $VERSION" --label "No Changelog Required" + + log "The release PR has been created " + log PR_URL + log Once approved and merged, run "./scripts/publish-release.sh $VERSION" again +} + + +publish-release() { + PR_NUMBER="$1" + if git ls-remote --exit-code --quiet --refs "origin/pull/$PR_NUMBER/merge"; then + log "PR #$PR_NUMBER is still open, please wait for it to be merged." + exit 1 + + log "Building and compressing static binaries" + for EXEC in "uplc pir plc"; do + nix build ".#hydraJobs.x86_64-linux.musl64.ghc96.$EXEC" + upx -9 ./result/bin/$EXEC -o "$EXEC-x86_64-linux-ghc96" --force-overwrite + done + + log "Tagging and publishing the release" + local TAG="$VERSION" + gh release create $TAG --title "$TAG" --generate-notes --latest + gh release upload $TAG pir-x86_64-linux-ghc96 uplc-x86_64-linux-ghc96 --clobber + + log "Cloning CHaP and making PR" + local COMMIT_SHA="$(git rev-parse --verify --quiet "$TAG")" + gh repo clone IntersectMBO/cardano-haskell-packages + cd cardano-haskell-packages + ./scripts-add-from-github "https://github.com/IntersectMBO/plutus" "$PLUTUS_COMMIT_SHA" plutus-core plutus-ledger-api plutus-tx plutus-tx-plugin + git add . + git commit -m "Plutus Release $VERSION" + git push + gh pr create --repo IntersectMBO/cardano-haskell-packages --title "Release $VERSION" --label + cd - + log "CHaP PR created at" + + log "Updating plutus-tx-template" + gh workflow run --repo IntersectMBO/plutus-tx-template --workflow=update-flake-inputs.yml bump-plutus-version --ref master --inputs version="$VERSION" + + log "Publishing the updated Metatheory site" + gh workflow run \ + --repo IntersectMBO/plutus \ + --workflow=metatheory-site.yml \ + --ref master \ + --inputs version="$VERSION" + + log "Publishing the updated haddock site" + gh workflow run \ + --repo IntersectMBO/plutus \ + --workflow=haddock-site.yml \ + --inputs destination="$VERSION" \ + --inputs ref="$VERSION" \ + --inputs latest=true \ + + log "Deleting unused tags" + git tag -d "release/$VERSION" +# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/haddock-site.yml[Haddock Site Action] on GitHub + +# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/metatheory-site.yml[Metatheory Site Action] on GitHub +# - Click the `Run workflow` button on the right, enter the new release version 2 times, leave the checkbox Enabled, and confirm +# - Ensure that the action completes successfully + +# 10. Publish the updated Haddock site +# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/haddock-site.yml[Haddock Site Action] on GitHub +# - Click the `Run workflow` button on the right, enter the new release version 2 times, leave the checkbox Enabled, and confirm +# - Ensure that the action completes successfully + +# 11. Delete unused branches and tags +# - If it was created, delete the `release/*` branch locally and on GitHub +# - If they were created, delete any release candidate `-rc*` tags locally and on GitHub + +} + diff --git a/scripts/update-version.sh b/scripts/update-version.sh deleted file mode 100755 index 975afe5ad30..00000000000 --- a/scripts/update-version.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash - -usage () { - echo "usage: $(basename $0) PACKAGE VERSION - Updates the version for PACKAGE to VERSION, and updates bounds - on that package in other cabal files." -} - -if [[ $# != 2 ]]; then - echo "Wrong number of arguments" - usage - exit 1 -fi - -set -euo pipefail - -PACKAGE=$1 -VERSION=$2 - -IFS='.' read -r -a components <<< "$VERSION" - -if [[ ${#components[@]} < 2 ]]; then - echo "Too few components in version number" $VERSION "(need at least two)" - usage - exit 1 -fi - -major_version="${components[0]}.${components[1]}" - -echo "Updating version of $PACKAGE to $VERSION" -# update package version in cabal file for package -sed -i "s/\(^version:\s*\).*/\1$VERSION/" "./$PACKAGE/$PACKAGE.cabal" - -# Update version bounds in all cabal files -# It looks for patterns like the following: -# -# - ", plutus-core" -# - ", plutus-core:uplc" -# - ", plutus-core ^>=1.0" -# - ", plutus-core:{plutus-core, plutus-core-testlib} ^>=1.0" -# -# and updates the version bounds to "^>={major version}" -# -# The ?* pattern prevents 'find' from attempting to modify ".cabal" (no basename). -# -# The pattern $PACKAGE[^-A-Za-z0-1][^^] matches the package name followed by the rest of the -# line up to but not including the first ^ (if any); anything after that is replaced with the -# new bound. We need [^-A-Za-z0-1] to exactly match the name of the package whose bounds we -# want to update and make sure that we don't get a situation like `plutus-tx` matching -# `plutus-tx-plugin`. -# -# The second sed command is to match the case where the package name is at the end of the line: -# we need this because the first case requires at least one character after the package name. -# -# Note that this all requires a comma (maybe preceded and/or followed by whitespace) at the -# start of the line: it won't work with a comma at the end. - -echo "Updating version bounds on $PACKAGE to '^>=$major_version'" -find . -name "?*.cabal" -exec sed -i "s/\(^[ \t]*,[ \t]*$PACKAGE[^-A-Za-z0-1][^^]*\).*/\1^>=$major_version/" {} \; \ - -exec sed -i "s/\(^[ \t]*,[ \t]*$PACKAGE$\)/\1 ^>=$major_version/" {} \; From 040beedef97f21c2293248de0d5451138b28657e Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 12 Dec 2024 14:25:50 +0100 Subject: [PATCH 03/21] wip --- .gitignore | 1 + scripts/publish-release.sh | 93 ++++++++++++++++++++------------------ 2 files changed, 50 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index ddd3d9163d8..56ac712ad24 100644 --- a/.gitignore +++ b/.gitignore @@ -113,3 +113,4 @@ plutus-pab/test-node/alonzo-purple/db *.timelog *.stacks .nvimrc +tmp-release-* diff --git a/scripts/publish-release.sh b/scripts/publish-release.sh index 1cbe978bf93..8591942d071 100644 --- a/scripts/publish-release.sh +++ b/scripts/publish-release.sh @@ -1,40 +1,25 @@ -set -euox pipefail +set -euo pipefail -VERSION="$1" - - -log() { - echo "*** RELEASE *** $1" -} - - -main() { - if [ "$(git rev-parse --abbrev-ref HEAD)" != "$VERSION" ]; then - log "No tag $VERSION found, creating a new release PR" - create-release-pr - else - log "Tag $VERSION found, publishing the release" - publish-release - fi +tell() { + echo "-------- RELEASE: $1" } create-release-pr() { - if ! git diff --quiet && git diff --cached --quiet; then - log "Uncommitted changes detected in your branch, please commit or stash them before running this script." - exit 1 - fi - if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - log "Invalid version $VERSION, expected format like 1.42.0.0" + tell "Invalid version '$VERSION', expecting something like 1.42.0.0" exit 1 fi - local MAJOR_VERSION="${VERSION%%.*}.${VERSION#*.}"; MAJOR_VERSION="${MAJOR_VERSION%%.*}" + if [[ -d "release-$VERSION" ]]; then + tell "Found worktree named 'tmp-release-$VERSION' in the current directory, I will delete it and start anew" + rm -r "tmp-release-$VERSION" + fi - log "Creating release branch release/$VERSION" - git checkout master + tell "Creating worketree and branch for $VERSION" + git worktree add tmp-release-$VERSION master + cd tmp-release-$VERSION git pull --rebase origin master git checkout -b release/$VERSION @@ -45,49 +30,52 @@ create-release-pr() { "plutus-tx-plugin" ) + local MAJOR_VERSION="$(echo "$VERSION" | cut -d'.' -f1,2)" + for PACKAGE in "${RELEASE_PACKAGES[@]}"; do - log "Updating ./$PACKAGE/$PACKAGE.cabal to ==$VERSION and ^>=$MAJOR_VERSION" + tell "Updating ./$PACKAGE/$PACKAGE.cabal to ==$VERSION and ^>=$MAJOR_VERSION" find . -name "?*.cabal" \ -exec sed -i "s/\(^version:\s*\).*/\1$VERSION/" "./$PACKAGE/$PACKAGE.cabal" \; \ -exec sed -i "s/\(^[ \t]*,[ \t]*$PACKAGE[^-A-Za-z0-1][^^]*\).*/\1^>=$MAJOR_VERSION/" {} \; \ -exec sed -i "s/\(^[ \t]*,[ \t]*$PACKAGE$\)/\1 ^>=$MAJOR_VERSION/" {} \; - log "Assembling changelog for $PACKAGE" + tell "Assembling changelog for $PACKAGE" pushd $PACKAGE > /dev/null scriv collect --version "$VERSION" popd > /dev/null done - log "Committing changes and creating PR on GitHub" + tell "Committing changes and creating PR on GitHub" git add . git commit -m "Release $VERSION" git push gh pr create --title "Release $VERSION" --label "No Changelog Required" - log "The release PR has been created " - log PR_URL - log Once approved and merged, run "./scripts/publish-release.sh $VERSION" again + tell "The release PR has been created " + tell "PR_URL" + tell "Once approved and merged, run './scripts/publish-release.sh $VERSION' again" } publish-release() { PR_NUMBER="$1" if git ls-remote --exit-code --quiet --refs "origin/pull/$PR_NUMBER/merge"; then - log "PR #$PR_NUMBER is still open, please wait for it to be merged." + tell "PR #$PR_NUMBER is still open, please wait for it to be merged." exit 1 + fi - log "Building and compressing static binaries" + tell "Building and compressing static binaries" for EXEC in "uplc pir plc"; do nix build ".#hydraJobs.x86_64-linux.musl64.ghc96.$EXEC" upx -9 ./result/bin/$EXEC -o "$EXEC-x86_64-linux-ghc96" --force-overwrite done - log "Tagging and publishing the release" + tell "Tagging and publishing the release" local TAG="$VERSION" gh release create $TAG --title "$TAG" --generate-notes --latest gh release upload $TAG pir-x86_64-linux-ghc96 uplc-x86_64-linux-ghc96 --clobber - log "Cloning CHaP and making PR" + tell "Cloning CHaP and making PR" local COMMIT_SHA="$(git rev-parse --verify --quiet "$TAG")" gh repo clone IntersectMBO/cardano-haskell-packages cd cardano-haskell-packages @@ -97,28 +85,30 @@ publish-release() { git push gh pr create --repo IntersectMBO/cardano-haskell-packages --title "Release $VERSION" --label cd - - log "CHaP PR created at" + tell "CHaP PR created at" - log "Updating plutus-tx-template" + tell "Updating plutus-tx-template" gh workflow run --repo IntersectMBO/plutus-tx-template --workflow=update-flake-inputs.yml bump-plutus-version --ref master --inputs version="$VERSION" - log "Publishing the updated Metatheory site" + tell "Publishing the updated Metatheory site" gh workflow run \ --repo IntersectMBO/plutus \ - --workflow=metatheory-site.yml \ + --workflow metatheory-site.yml \ --ref master \ --inputs version="$VERSION" - log "Publishing the updated haddock site" + tell "Publishing the updated haddock site" gh workflow run \ --repo IntersectMBO/plutus \ - --workflow=haddock-site.yml \ + --workflow haddock-site.yml \ --inputs destination="$VERSION" \ --inputs ref="$VERSION" \ --inputs latest=true \ - log "Deleting unused tags" + tell "Deleting unused tags" git tag -d "release/$VERSION" +} + # - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/haddock-site.yml[Haddock Site Action] on GitHub # - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/metatheory-site.yml[Metatheory Site Action] on GitHub @@ -134,5 +124,20 @@ publish-release() { # - If it was created, delete the `release/*` branch locally and on GitHub # - If they were created, delete any release candidate `-rc*` tags locally and on GitHub -} +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + + +VERSION="$1" + + +if ! git ls-remote --heads origin "release/$VERSION" &>/dev/null; then + tell "I could not find the origin branch named 'release/$VERSION' so I will begin a new release process for $VERSION" + create-release-pr +else + tell "I found the origin branch named 'release/$VERSION' so I will continue the release process for $VERSION" + # publish-release +fi From 2facd0c1c1f30d3658f87f950ee1ddc22959c44a Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 12 Dec 2024 14:33:09 +0100 Subject: [PATCH 04/21] wip --- .gitignore | 2 +- scripts/publish-release.sh | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 56ac712ad24..407a65748d8 100644 --- a/.gitignore +++ b/.gitignore @@ -113,4 +113,4 @@ plutus-pab/test-node/alonzo-purple/db *.timelog *.stacks .nvimrc -tmp-release-* +release-* diff --git a/scripts/publish-release.sh b/scripts/publish-release.sh index 8591942d071..08b3b386244 100644 --- a/scripts/publish-release.sh +++ b/scripts/publish-release.sh @@ -7,19 +7,14 @@ tell() { create-release-pr() { - if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - tell "Invalid version '$VERSION', expecting something like 1.42.0.0" - exit 1 - fi - if [[ -d "release-$VERSION" ]]; then - tell "Found worktree named 'tmp-release-$VERSION' in the current directory, I will delete it and start anew" - rm -r "tmp-release-$VERSION" + tell "Found worktree named 'release-$VERSION' in the current directory, I will delete it and start anew" + rm -r "release-$VERSION" fi tell "Creating worketree and branch for $VERSION" - git worktree add tmp-release-$VERSION master - cd tmp-release-$VERSION + git worktree add release-$VERSION master + cd release-$VERSION git pull --rebase origin master git checkout -b release/$VERSION @@ -134,7 +129,13 @@ fi VERSION="$1" -if ! git ls-remote --heads origin "release/$VERSION" &>/dev/null; then +if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + tell "Invalid version '$VERSION', expecting something like 1.42.0.0" + exit 1 +fi + + +if [[ $(git ls-remote --heads origin "release/$VERSION") == "" ]]; then tell "I could not find the origin branch named 'release/$VERSION' so I will begin a new release process for $VERSION" create-release-pr else From 84dad2e67b4fac83329661faef05e14443403571 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 12 Dec 2024 14:51:55 +0100 Subject: [PATCH 05/21] wip --- scripts/publish-release.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/publish-release.sh b/scripts/publish-release.sh index 08b3b386244..fa30c33ccd6 100644 --- a/scripts/publish-release.sh +++ b/scripts/publish-release.sh @@ -2,14 +2,15 @@ set -euo pipefail tell() { - echo "-------- RELEASE: $1" + echo "---------- RELEASE ---------- $1" } create-release-pr() { if [[ -d "release-$VERSION" ]]; then tell "Found worktree named 'release-$VERSION' in the current directory, I will delete it and start anew" - rm -r "release-$VERSION" + git worktree remove --force release-$VERSION + git branch -D release/$VERSION fi tell "Creating worketree and branch for $VERSION" @@ -36,15 +37,16 @@ create-release-pr() { tell "Assembling changelog for $PACKAGE" pushd $PACKAGE > /dev/null - scriv collect --version "$VERSION" + scriv collect --version "$VERSION" || true popd > /dev/null done tell "Committing changes and creating PR on GitHub" git add . + pre-commit run cabal-fmt git commit -m "Release $VERSION" - git push - gh pr create --title "Release $VERSION" --label "No Changelog Required" + git push --force + # gh pr create --title "Release $VERSION" --body "Release $VERSION" --label "No Changelog Required" tell "The release PR has been created " tell "PR_URL" From 50bf66c7de3ae93ec8e4dfde85f8087694a242e4 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 12 Dec 2024 16:10:12 +0100 Subject: [PATCH 06/21] wip --- scripts/publish-release.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/publish-release.sh b/scripts/publish-release.sh index fa30c33ccd6..543c52e2e0d 100644 --- a/scripts/publish-release.sh +++ b/scripts/publish-release.sh @@ -42,14 +42,21 @@ create-release-pr() { done tell "Committing changes and creating PR on GitHub" + cp ../.pre-commit-config.yaml .pre-commit-config.yaml git add . - pre-commit run cabal-fmt - git commit -m "Release $VERSION" + pre-commit run cabal-fmt || true + git add . + git commit -m "Release $VERSION" || true git push --force - # gh pr create --title "Release $VERSION" --body "Release $VERSION" --label "No Changelog Required" - - tell "The release PR has been created " - tell "PR_URL" + gh pr create \ + --title "Release $VERSION" \ + --body "Release $VERSION" \ + --label "No Changelog Required" \ + --head release/$VERSION \ + --base master + + tell "" + tell "The release PR has been created, see URL above." tell "Once approved and merged, run './scripts/publish-release.sh $VERSION' again" } @@ -143,4 +150,6 @@ if [[ $(git ls-remote --heads origin "release/$VERSION") == "" ]]; then else tell "I found the origin branch named 'release/$VERSION' so I will continue the release process for $VERSION" # publish-release + create-release-pr + fi From 9a16eae1911db18c6f62b37eecff27449b8d4683 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 12 Dec 2024 17:01:42 +0100 Subject: [PATCH 07/21] wip --- ...lish-release.sh => interactive-release.sh} | 98 ++++++++++++++----- 1 file changed, 72 insertions(+), 26 deletions(-) rename scripts/{publish-release.sh => interactive-release.sh} (62%) diff --git a/scripts/publish-release.sh b/scripts/interactive-release.sh similarity index 62% rename from scripts/publish-release.sh rename to scripts/interactive-release.sh index 543c52e2e0d..f2ddc058f73 100644 --- a/scripts/publish-release.sh +++ b/scripts/interactive-release.sh @@ -1,8 +1,11 @@ set -euo pipefail +VERSION="" + + tell() { - echo "---------- RELEASE ---------- $1" + echo "RELEASE 🚀🚀🚀 $1" } @@ -28,14 +31,13 @@ create-release-pr() { local MAJOR_VERSION="$(echo "$VERSION" | cut -d'.' -f1,2)" + tell "Updating ./$PACKAGE/$PACKAGE.cabal to ==$VERSION and ^>=$MAJOR_VERSION" for PACKAGE in "${RELEASE_PACKAGES[@]}"; do - tell "Updating ./$PACKAGE/$PACKAGE.cabal to ==$VERSION and ^>=$MAJOR_VERSION" find . -name "?*.cabal" \ -exec sed -i "s/\(^version:\s*\).*/\1$VERSION/" "./$PACKAGE/$PACKAGE.cabal" \; \ -exec sed -i "s/\(^[ \t]*,[ \t]*$PACKAGE[^-A-Za-z0-1][^^]*\).*/\1^>=$MAJOR_VERSION/" {} \; \ -exec sed -i "s/\(^[ \t]*,[ \t]*$PACKAGE$\)/\1 ^>=$MAJOR_VERSION/" {} \; - tell "Assembling changelog for $PACKAGE" pushd $PACKAGE > /dev/null scriv collect --version "$VERSION" || true popd > /dev/null @@ -57,17 +59,11 @@ create-release-pr() { tell "" tell "The release PR has been created, see URL above." - tell "Once approved and merged, run './scripts/publish-release.sh $VERSION' again" + tell "Once approved and merged, run './scripts/interactive-release.sh' again" } -publish-release() { - PR_NUMBER="$1" - if git ls-remote --exit-code --quiet --refs "origin/pull/$PR_NUMBER/merge"; then - tell "PR #$PR_NUMBER is still open, please wait for it to be merged." - exit 1 - fi - +publish-gh-release() { tell "Building and compressing static binaries" for EXEC in "uplc pir plc"; do nix build ".#hydraJobs.x86_64-linux.musl64.ghc96.$EXEC" @@ -129,27 +125,77 @@ publish-release() { # - If they were created, delete any release candidate `-rc*` tags locally and on GitHub -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi +# if [ "$#" -ne 1 ]; then +# echo "Usage: $0 " +# exit 1 +# fi -VERSION="$1" +# VERSION="$1" -if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - tell "Invalid version '$VERSION', expecting something like 1.42.0.0" - exit 1 -fi +# if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then +# tell "Invalid version '$VERSION', expecting something like 1.42.0.0" +# exit 1 +# fi -if [[ $(git ls-remote --heads origin "release/$VERSION") == "" ]]; then - tell "I could not find the origin branch named 'release/$VERSION' so I will begin a new release process for $VERSION" - create-release-pr +# if [[ $(git ls-remote --heads origin "release/$VERSION") == "" ]]; then +# tell "I could not find the origin branch named 'release/$VERSION' so I will begin a new release process for $VERSION" +# create-release-pr +# else +# tell "I found the origin branch named 'release/$VERSION' so I will continue the release process for $VERSION" +# # publish-release +# create-release-pr + +# fi + + +tell "Starting the interactive release process" + +while true; do + read -p "Enter the version number for this release, for example 1.42.0.0: " VERSION + if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + tell "Invalid version '$VERSION', expecting something like 1.42.0.0" + else + tell "Will release version '$VERSION'" + break + fi +done + + +tell "Checking if a PR for release/$VERSION already exists" +PR_NUMBER="$(gh pr list --head release/$VERSION --json number --jq ".[0].number" +if [[ -n "$PR_NUMBER" ]]; then + PR_URL="https://github.com/IntersectMBO/plutus/pull/$PR_NUMBER" + tell "Found PR for release/$VERSION at $PR_URL" + tell "Checking the state of that PR" + PR_STATE="$(gh pr view $PR_NUMBER --json state --jq ".state")" + if [[ "$PR_STATE" == "OPEN" ]]; then + tell "It is still open, please wait for it to be merged before running this command again." + exit 1 + else if [[ "$PR_STATE" == "MERGED" ]]; then + tell "It is merged, I will now look for release $VERSION" + RELEASE_URL="$(gh release view $VERSION --json url --jq ".url")" + if [[ "$RELEASE_URL" == "release not found" ]]; then + tell "No release found for $VERSION, I will publish it now" + publish-gh-release + else + tell "I already found a release for version $VERSION at $RELEASE_URL" + tell "I will now proceed to check the CHaP and Metatheory PRs" + exit 1 + fi + else if [[ "$PR_STATE" == "CLOSED" ]]; then + tell "It is closed, you might want to re-open it" + exit 1 + else + tell "Unknown state '$PR_STATE', please check the PR at $PR_URL" + exit 1 + fi else - tell "I found the origin branch named 'release/$VERSION' so I will continue the release process for $VERSION" - # publish-release + tell "No PR found for release/$VERSION, I will start the release process" create-release-pr - fi + +# if [[ $(git ls-remote --heads origin "release/$VERSION") == "" ]]; then + From 0aa45a4ed9a0cf4a48edbbe0bfaede762e01367d Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 12 Dec 2024 17:10:53 +0100 Subject: [PATCH 08/21] wgipo --- scripts/interactive-release.sh | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) mode change 100644 => 100755 scripts/interactive-release.sh diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh old mode 100644 new mode 100755 index f2ddc058f73..8667d00ab2e --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -5,7 +5,14 @@ VERSION="" tell() { - echo "RELEASE 🚀🚀🚀 $1" + echo "🚀🚀🚀 $1" +} + + +ask() { + local MSG="$1" + read -p "🚀🚀🚀 $MSG" RESPONSE + echo "$RESPONSE" } @@ -154,28 +161,24 @@ publish-gh-release() { tell "Starting the interactive release process" while true; do - read -p "Enter the version number for this release, for example 1.42.0.0: " VERSION + VERSION=$(ask "Enter the version number for this release, for example 1.42.0.0: ") if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then tell "Invalid version '$VERSION', expecting something like 1.42.0.0" else - tell "Will release version '$VERSION'" break fi done -tell "Checking if a PR for release/$VERSION already exists" -PR_NUMBER="$(gh pr list --head release/$VERSION --json number --jq ".[0].number" +PR_NUMBER="$(gh pr list --head release/$VERSION --json number --jq ".[0].number")" if [[ -n "$PR_NUMBER" ]]; then PR_URL="https://github.com/IntersectMBO/plutus/pull/$PR_NUMBER" - tell "Found PR for release/$VERSION at $PR_URL" - tell "Checking the state of that PR" PR_STATE="$(gh pr view $PR_NUMBER --json state --jq ".state")" if [[ "$PR_STATE" == "OPEN" ]]; then - tell "It is still open, please wait for it to be merged before running this command again." + tell "Found open PR for release/$VERSION at $PR_URL, please wait for it to be merged before running this command again." exit 1 - else if [[ "$PR_STATE" == "MERGED" ]]; then - tell "It is merged, I will now look for release $VERSION" + elif [[ "$PR_STATE" == "MERGED" ]]; then + tell "Found merged PR for release/$VERSION at $PR_URL, I will now look for a release tagged '$VERSION'" RELEASE_URL="$(gh release view $VERSION --json url --jq ".url")" if [[ "$RELEASE_URL" == "release not found" ]]; then tell "No release found for $VERSION, I will publish it now" @@ -185,11 +188,11 @@ if [[ -n "$PR_NUMBER" ]]; then tell "I will now proceed to check the CHaP and Metatheory PRs" exit 1 fi - else if [[ "$PR_STATE" == "CLOSED" ]]; then - tell "It is closed, you might want to re-open it" + elif [[ "$PR_STATE" == "CLOSED" ]]; then + tell "Found closed PR for release/$VERSION at $PR_UR, you might want to re-open it" exit 1 else - tell "Unknown state '$PR_STATE', please check the PR at $PR_URL" + tell "Found PR for release/$VERSION at $PR_UR with unknown state '$PR_STATE', please double check" exit 1 fi else From 9b58378ebe0db1acc744579f82b499a151fa1a51 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 19 Dec 2024 14:46:30 +0100 Subject: [PATCH 09/21] Merging --- nix/shell.nix | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/nix/shell.nix b/nix/shell.nix index 32787c4638b..1807bc66b17 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -78,24 +78,6 @@ in { packages = lib.concatLists [ all-pkgs linux-pkgs ]; - scripts.assemble-changelog = { - description = "Assembles the changelog for PACKAGE at VERSION"; - exec = repoRoot.scripts."assemble-changelog.sh"; - group = "changelog"; - }; - - scripts.prepare-release = { - description = "Prepares to release PACKAGEs at VERSION"; - exec = repoRoot.scripts."prepare-release.sh"; - group = "changelog"; - }; - - scripts.update-version = { - description = "Updates the version for PACKAGE to VERSION"; - exec = repoRoot.scripts."update-version.sh"; - group = "changelog"; - }; - shellHook = '' ${builtins.readFile certEnv} ''; From a59daab5baffa677c48656bfe5acba9a53a243d0 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 19 Dec 2024 15:12:07 +0100 Subject: [PATCH 10/21] wip --- scripts/interactive-release.sh | 118 ++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 54 deletions(-) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index 8667d00ab2e..7dfd80cc1ce 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -38,7 +38,7 @@ create-release-pr() { local MAJOR_VERSION="$(echo "$VERSION" | cut -d'.' -f1,2)" - tell "Updating ./$PACKAGE/$PACKAGE.cabal to ==$VERSION and ^>=$MAJOR_VERSION" + tell "Updating cabal packages to ==$VERSION and ^>=$MAJOR_VERSION" for PACKAGE in "${RELEASE_PACKAGES[@]}"; do find . -name "?*.cabal" \ -exec sed -i "s/\(^version:\s*\).*/\1$VERSION/" "./$PACKAGE/$PACKAGE.cabal" \; \ @@ -57,15 +57,16 @@ create-release-pr() { git add . git commit -m "Release $VERSION" || true git push --force - gh pr create \ + + PR_URL=$(gh pr create \ --title "Release $VERSION" \ --body "Release $VERSION" \ --label "No Changelog Required" \ --head release/$VERSION \ - --base master + --base master \ + | grep "https://") - tell "" - tell "The release PR has been created, see URL above." + tell "The release PR has been created at $PR_URL" tell "Once approved and merged, run './scripts/interactive-release.sh' again" } @@ -90,76 +91,44 @@ publish-gh-release() { git add . git commit -m "Plutus Release $VERSION" git push - gh pr create --repo IntersectMBO/cardano-haskell-packages --title "Release $VERSION" --label + PR_URL=$(gh pr create \ + --repo IntersectMBO/cardano-haskell-packages \ + --title "Release $VERSION" \ + --body "Release $VERSION" \ + | grep "https://") cd - - tell "CHaP PR created at" + tell "CHaP PR created at $PR_URL" - tell "Updating plutus-tx-template" - gh workflow run --repo IntersectMBO/plutus-tx-template --workflow=update-flake-inputs.yml bump-plutus-version --ref master --inputs version="$VERSION" + tell "Bumping plutus version in plutus-tx-template" + gh workflow run \ + --repo IntersectMBO/plutus-tx-template \ + --workflow bump-plutus-version.yml \ + --inputs version=$VERSION \ tell "Publishing the updated Metatheory site" gh workflow run \ --repo IntersectMBO/plutus \ --workflow metatheory-site.yml \ - --ref master \ - --inputs version="$VERSION" + --inputs ref=$VERSION \ + --inputs destination="$VERSION" \ + --inputs latest=true tell "Publishing the updated haddock site" gh workflow run \ --repo IntersectMBO/plutus \ --workflow haddock-site.yml \ - --inputs destination="$VERSION" \ --inputs ref="$VERSION" \ - --inputs latest=true \ + --inputs destination="$VERSION" \ + --inputs latest=true tell "Deleting unused tags" git tag -d "release/$VERSION" } -# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/haddock-site.yml[Haddock Site Action] on GitHub - -# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/metatheory-site.yml[Metatheory Site Action] on GitHub -# - Click the `Run workflow` button on the right, enter the new release version 2 times, leave the checkbox Enabled, and confirm -# - Ensure that the action completes successfully - -# 10. Publish the updated Haddock site -# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/haddock-site.yml[Haddock Site Action] on GitHub -# - Click the `Run workflow` button on the right, enter the new release version 2 times, leave the checkbox Enabled, and confirm -# - Ensure that the action completes successfully - -# 11. Delete unused branches and tags -# - If it was created, delete the `release/*` branch locally and on GitHub -# - If they were created, delete any release candidate `-rc*` tags locally and on GitHub - - -# if [ "$#" -ne 1 ]; then -# echo "Usage: $0 " -# exit 1 -# fi - - -# VERSION="$1" - - -# if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then -# tell "Invalid version '$VERSION', expecting something like 1.42.0.0" -# exit 1 -# fi - - -# if [[ $(git ls-remote --heads origin "release/$VERSION") == "" ]]; then -# tell "I could not find the origin branch named 'release/$VERSION' so I will begin a new release process for $VERSION" -# create-release-pr -# else -# tell "I found the origin branch named 'release/$VERSION' so I will continue the release process for $VERSION" -# # publish-release -# create-release-pr - -# fi - tell "Starting the interactive release process" + while true; do VERSION=$(ask "Enter the version number for this release, for example 1.42.0.0: ") if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then @@ -202,3 +171,44 @@ fi # if [[ $(git ls-remote --heads origin "release/$VERSION") == "" ]]; then + +# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/haddock-site.yml[Haddock Site Action] on GitHub + +# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/metatheory-site.yml[Metatheory Site Action] on GitHub +# - Click the `Run workflow` button on the right, enter the new release version 2 times, leave the checkbox Enabled, and confirm +# - Ensure that the action completes successfully + +# 10. Publish the updated Haddock site +# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/haddock-site.yml[Haddock Site Action] on GitHub +# - Click the `Run workflow` button on the right, enter the new release version 2 times, leave the checkbox Enabled, and confirm +# - Ensure that the action completes successfully + +# 11. Delete unused branches and tags +# - If it was created, delete the `release/*` branch locally and on GitHub +# - If they were created, delete any release candidate `-rc*` tags locally and on GitHub + + +# if [ "$#" -ne 1 ]; then +# echo "Usage: $0 " +# exit 1 +# fi + + +# VERSION="$1" + + +# if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then +# tell "Invalid version '$VERSION', expecting something like 1.42.0.0" +# exit 1 +# fi + + +# if [[ $(git ls-remote --heads origin "release/$VERSION") == "" ]]; then +# tell "I could not find the origin branch named 'release/$VERSION' so I will begin a new release process for $VERSION" +# create-release-pr +# else +# tell "I found the origin branch named 'release/$VERSION' so I will continue the release process for $VERSION" +# # publish-release +# create-release-pr + +# fi From efa6bce74fc04cc1a28e7cfcddfcec9b5ef9fe47 Mon Sep 17 00:00:00 2001 From: zeme Date: Fri, 20 Dec 2024 10:00:34 +0100 Subject: [PATCH 11/21] Delete Comments --- scripts/interactive-release.sh | 46 +--------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index 7dfd80cc1ce..e648ee7af60 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -167,48 +167,4 @@ if [[ -n "$PR_NUMBER" ]]; then else tell "No PR found for release/$VERSION, I will start the release process" create-release-pr -fi - -# if [[ $(git ls-remote --heads origin "release/$VERSION") == "" ]]; then - - -# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/haddock-site.yml[Haddock Site Action] on GitHub - -# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/metatheory-site.yml[Metatheory Site Action] on GitHub -# - Click the `Run workflow` button on the right, enter the new release version 2 times, leave the checkbox Enabled, and confirm -# - Ensure that the action completes successfully - -# 10. Publish the updated Haddock site -# - Navigate to the https://github.com/IntersectMBO/plutus/actions/workflows/haddock-site.yml[Haddock Site Action] on GitHub -# - Click the `Run workflow` button on the right, enter the new release version 2 times, leave the checkbox Enabled, and confirm -# - Ensure that the action completes successfully - -# 11. Delete unused branches and tags -# - If it was created, delete the `release/*` branch locally and on GitHub -# - If they were created, delete any release candidate `-rc*` tags locally and on GitHub - - -# if [ "$#" -ne 1 ]; then -# echo "Usage: $0 " -# exit 1 -# fi - - -# VERSION="$1" - - -# if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then -# tell "Invalid version '$VERSION', expecting something like 1.42.0.0" -# exit 1 -# fi - - -# if [[ $(git ls-remote --heads origin "release/$VERSION") == "" ]]; then -# tell "I could not find the origin branch named 'release/$VERSION' so I will begin a new release process for $VERSION" -# create-release-pr -# else -# tell "I found the origin branch named 'release/$VERSION' so I will continue the release process for $VERSION" -# # publish-release -# create-release-pr - -# fi +fi \ No newline at end of file From 6573663016c45b94eb25a8c52dec620ac94a9293 Mon Sep 17 00:00:00 2001 From: zeme Date: Fri, 20 Dec 2024 10:13:12 +0100 Subject: [PATCH 12/21] Add github-cli to the shell --- nix/shell.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nix/shell.nix b/nix/shell.nix index 1807bc66b17..e8952becb12 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -50,6 +50,7 @@ let pkgs.scriv pkgs.fswatch pkgs.yarn + pkgs.github-cli # This is used to get `taskset` for ./scripts/ci-plutus-benchmark.sh, but # it's not available on macOS. From 66ec4f04dc0a90388e1a5aa06c17b71d72ab0651 Mon Sep 17 00:00:00 2001 From: zeme Date: Fri, 20 Dec 2024 10:15:14 +0100 Subject: [PATCH 13/21] Delete Comments --- scripts/interactive-release.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index e648ee7af60..0f64de68d4f 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -1,3 +1,5 @@ +#! /usr/bin/env bash + set -euo pipefail From d1a492c5d7fe0026d78fd078ca5a4247191968f4 Mon Sep 17 00:00:00 2001 From: zeme Date: Fri, 20 Dec 2024 10:18:49 +0100 Subject: [PATCH 14/21] Set upstream when pushing --- scripts/interactive-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index 0f64de68d4f..43f7acd91ba 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -58,7 +58,7 @@ create-release-pr() { pre-commit run cabal-fmt || true git add . git commit -m "Release $VERSION" || true - git push --force + git push --force --set-upstream origin release/$VERSION PR_URL=$(gh pr create \ --title "Release $VERSION" \ From 97b32be8e0b0a473a16ebbb4378f60995cafacd9 Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 24 Dec 2024 19:20:23 +0100 Subject: [PATCH 15/21] Improvements --- scripts/interactive-release.sh | 377 ++++++++++++++++++++++++--------- 1 file changed, 278 insertions(+), 99 deletions(-) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index 43f7acd91ba..5a2c9735bda 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -1,35 +1,111 @@ #! /usr/bin/env bash -set -euo pipefail +# The release process is interactive and consists of the following steps: +# +# 1. Open a new Release PR in plutus +# 2. Review and approve the Release PR in plutus, do not merge it yet +# 3. Open and merge a new Plutus Release PR in CHaP +# 4. Open and merge a new Plutus Update PR in plutus-tx-template +# 5. Merge the original Release PR in plutus +# 6. Publish the release on GitHub +# 7. Deploy the Haddock site for the new release +# 8. Deploy the Metatheory site for the new release +# +# Each of these steps depend on the previous one, so it's important to follow them in order. +# Each step is idempotent, so you can run the script multiple times if needed. +# +# Usage: ./scripts/interactive-release.sh VERSION -VERSION="" +set -euo pipefail tell() { - echo "🚀🚀🚀 $1" + echo -e "🚀 $1" } ask() { - local MSG="$1" - read -p "🚀🚀🚀 $MSG" RESPONSE + local MESSAGE="$1" + read -p "🚀 $MESSAGE" RESPONSE echo "$RESPONSE" } -create-release-pr() { - if [[ -d "release-$VERSION" ]]; then - tell "Found worktree named 'release-$VERSION' in the current directory, I will delete it and start anew" - git worktree remove --force release-$VERSION - git branch -D release/$VERSION - fi +get-pr-number() { + local REPO=$1 + local BRANCH=$2 + gh pr list --repo $REPO --state all --head $BRANCH --json number --jq ".[0].number" +} + + +get-pr-url() { + local REPO=$1 + local BRANCH=$2 + echo "https://github.com/$REPO/pull/$(get-pr-number $REPO $BRANCH)" +} + + +get-pr-state() { + local REPO=$1 + local BRANCH=$2 + local PR_NUMBER=$(get-pr-number $REPO $BRANCH) + if [[ -z $PR_NUMBER ]]; then + echo MISSING + else + gh pr view $PR_NUMBER --repo $REPO --json state --jq ".state" + fi +} + + +maybe-open-pr() { + local REPO=$1 + local BRANCH=$2 + local COMMAND=$3 + + local PR_NUMBER=$(get-pr-number $REPO $BRANCH) + local PR_URL=$(get-pr-url $REPO $BRANCH) + local PR_STATE=$(get-pr-state $REPO $BRANCH) + + if [[ -z $PR_NUMBER ]]; then + tell "No PR found with in $REPO with branch $BRANCH, I will create the PR" + $COMMAND + else + case $PR_STATE in + "MERGED") + tell "Found merged PR in $REPO for $BRANCH at $PR_URL" + ;; + "OPEN") + tell "Found open PR in $REPO for $BRANCH at $PR_URL" + ;; + "CLOSED") + tell "Found closed PR in $REPO for $BRANCH at $PR_URL" + tell "This is odd, please re-open the PR and try again" + ;; + *) + tell "Found PR in $REPO for $BRANCH at $PR_URL with invalid state $PR_STATE" + ;; + esac + fi +} + + +check-and-open-plutus-pr() { + maybe-open-pr IntersectMBO/plutus "release/$VERSION" open-plutus-pr +} - tell "Creating worketree and branch for $VERSION" - git worktree add release-$VERSION master - cd release-$VERSION + +open-plutus-pr() { + local PR_BRANCH="release/$VERSION" + local PR_WORKTREE="release-$VERSION" + + git worktree remove --force $PR_WORKTREE || true + git branch -D $PR_BRANCH || true + + git worktree add $PR_WORKTREE master + cd $PR_WORKTREE git pull --rebase origin master - git checkout -b release/$VERSION + git checkout -b $PR_BRANCH local RELEASE_PACKAGES=( "plutus-core" @@ -38,9 +114,8 @@ create-release-pr() { "plutus-tx-plugin" ) - local MAJOR_VERSION="$(echo "$VERSION" | cut -d'.' -f1,2)" + local MAJOR_VERSION=$(echo $VERSION | cut -d'.' -f1,2) - tell "Updating cabal packages to ==$VERSION and ^>=$MAJOR_VERSION" for PACKAGE in "${RELEASE_PACKAGES[@]}"; do find . -name "?*.cabal" \ -exec sed -i "s/\(^version:\s*\).*/\1$VERSION/" "./$PACKAGE/$PACKAGE.cabal" \; \ @@ -48,125 +123,229 @@ create-release-pr() { -exec sed -i "s/\(^[ \t]*,[ \t]*$PACKAGE$\)/\1 ^>=$MAJOR_VERSION/" {} \; pushd $PACKAGE > /dev/null - scriv collect --version "$VERSION" || true + scriv collect --version $VERSION || true popd > /dev/null done - tell "Committing changes and creating PR on GitHub" cp ../.pre-commit-config.yaml .pre-commit-config.yaml git add . pre-commit run cabal-fmt || true git add . git commit -m "Release $VERSION" || true - git push --force --set-upstream origin release/$VERSION + git push --force --set-upstream origin $PR_BRANCH - PR_URL=$(gh pr create \ + local PR_URL=$(gh pr create \ --title "Release $VERSION" \ --body "Release $VERSION" \ --label "No Changelog Required" \ - --head release/$VERSION \ + --head $PR_BRANCH \ --base master \ | grep "https://") + git worktree remove --force $PR_WORKTREE + git branch -D $PR_BRANCH + tell "The release PR has been created at $PR_URL" - tell "Once approved and merged, run './scripts/interactive-release.sh' again" } -publish-gh-release() { - tell "Building and compressing static binaries" - for EXEC in "uplc pir plc"; do - nix build ".#hydraJobs.x86_64-linux.musl64.ghc96.$EXEC" - upx -9 ./result/bin/$EXEC -o "$EXEC-x86_64-linux-ghc96" --force-overwrite - done +check-and-open-chap-pr() { + maybe-open-pr IntersectMBO/cardano-haskell-packages "plutus-release/$VERSION" open-chap-pr +} + + +check-plutus-pr-review-status() { + tell "Ensure that CI passes and the PR is approved before running step 3" +} - tell "Tagging and publishing the release" - local TAG="$VERSION" - gh release create $TAG --title "$TAG" --generate-notes --latest - gh release upload $TAG pir-x86_64-linux-ghc96 uplc-x86_64-linux-ghc96 --clobber - tell "Cloning CHaP and making PR" - local COMMIT_SHA="$(git rev-parse --verify --quiet "$TAG")" - gh repo clone IntersectMBO/cardano-haskell-packages +open-chap-pr() { + local PR_BRANCH="plutus-release/$VERSION" + rm -rf cardano-haskell-packages || true + git fetch --tags + local COMMIT_SHA=$(git rev-parse --verify --quiet $VERSION) + gh repo clone IntersectMBO/cardano-haskell-packages -- --single-branch --branch main cd cardano-haskell-packages - ./scripts-add-from-github "https://github.com/IntersectMBO/plutus" "$PLUTUS_COMMIT_SHA" plutus-core plutus-ledger-api plutus-tx plutus-tx-plugin - git add . - git commit -m "Plutus Release $VERSION" - git push - PR_URL=$(gh pr create \ + git checkout -b $PR_BRANCH + ./scripts/add-from-github.sh https://github.com/IntersectMBO/plutus $COMMIT_SHA plutus-core plutus-ledger-api plutus-tx plutus-tx-plugin + git push --force --set-upstream origin $PR_BRANCH + local PR_URL=$(gh pr create \ --repo IntersectMBO/cardano-haskell-packages \ - --title "Release $VERSION" \ - --body "Release $VERSION" \ + --title "Plutus Release $VERSION" \ + --body "Plutus Release $VERSION" \ + --head $PR_BRANCH \ + --base main \ | grep "https://") cd - - tell "CHaP PR created at $PR_URL" + rm -rf cardano-haskell-packages || true + tell "The release PR has been created at $PR_URL" +} + + +check-and-publish-gh-release() { + local RELEASE_URL="$(gh release view 1.38.0.0 --json url --jq ".url" 2>&1)" + if [[ $RELEASE_URL == "release not found" ]]; then + tell "No release found for $VERSION, I will publish it now" + publish-gh-release + else + tell "Found a release for version $VERSION at $RELEASE_URL" + fi +} + - tell "Bumping plutus version in plutus-tx-template" - gh workflow run \ +publish-gh-release() { + for EXEC in uplc pir plc; do + nix build ".#hydraJobs.x86_64-linux.musl64.ghc96.$EXEC" + upx -9 ./result/bin/$EXEC -o $EXEC-x86_64-linux-ghc96 --force-overwrite + done + gh release create $VERSION --title $VERSION --generate-notes --latest + gh release upload $VERSION {uplc,plc,pir}-x86_64-linux-ghc96 --clobber + tell "Published the release" +} + + +check-and-open-plutus-tx-pr() { + maybe-open-pr IntersectMBO/plutus-tx-template "bump-plutus-$VERSION" open-plutus-tx-pr +} + + +merge-plutus-pr() { + local A=1 +} + + +open-plutus-tx-pr() { + gh workflow run bump-plutus-version.yml \ --repo IntersectMBO/plutus-tx-template \ - --workflow bump-plutus-version.yml \ - --inputs version=$VERSION \ + --field version=$VERSION +} - tell "Publishing the updated Metatheory site" - gh workflow run \ + +deploy-metatheory-site() { + gh workflow run metatheory-site.yml \ --repo IntersectMBO/plutus \ - --workflow metatheory-site.yml \ - --inputs ref=$VERSION \ - --inputs destination="$VERSION" \ - --inputs latest=true - - tell "Publishing the updated haddock site" - gh workflow run \ + --field ref=$VERSION \ + --field destination=$VERSION \ + --field latest=true +} + + +deploy-haddock-site() { + gh workflow run haddock-site.yml \ --repo IntersectMBO/plutus \ - --workflow haddock-site.yml \ - --inputs ref="$VERSION" \ - --inputs destination="$VERSION" \ - --inputs latest=true + --field ref=$VERSION \ + --field destination=$VERSION \ + --field latest=true +} + - tell "Deleting unused tags" - git tag -d "release/$VERSION" +print-usage() { + echo "Usage: $0 VERSION" + echo + echo " VERSION is required and should be a version number like 1.42.0.0" } -tell "Starting the interactive release process" +print-status() { + echo "1 Open a new Release PR in plutus" + local PR_URL=$(get-pr-url IntersectMBO/plutus "release/$VERSION") + local PR_STATE=$(get-pr-state IntersectMBO/plutus "release/$VERSION") + if [[ $PR_STATE == "OPEN" || $PR_STATE == "MERGED" ]]; then + echo -e "✅ PR $PR_STATE at $PR_URL" + else + echo "❌ PR $PR_STATE" + fi + echo "2 Wait for CI checks, review and approve the Release PR in plutus, do not merge it yet" + if [[ $PR_STATE == "OPEN" || $PR_STATE == "MERGED" ]]; then + echo "✅ PR $PR_STATE at $PR_URL" + else + echo "❌ PR $PR_STATE" + fi -while true; do - VERSION=$(ask "Enter the version number for this release, for example 1.42.0.0: ") - if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - tell "Invalid version '$VERSION', expecting something like 1.42.0.0" + echo "3 Open and merge a new Plutus Release PR in CHaP" + PR_URL=$(get-pr-url IntersectMBO/cardano-haskell-packages "plutus-release/$VERSION") + PR_STATE=$(get-pr-state IntersectMBO/cardano-haskell-packages "plutus-release/$VERSION") + if [[ $PR_STATE == "OPEN" || $PR_STATE == "MERGED" ]]; then + echo "✅ PR $PR_STATE at $PR_URL" else - break + echo "❌ PR $PR_STATE" fi -done - - -PR_NUMBER="$(gh pr list --head release/$VERSION --json number --jq ".[0].number")" -if [[ -n "$PR_NUMBER" ]]; then - PR_URL="https://github.com/IntersectMBO/plutus/pull/$PR_NUMBER" - PR_STATE="$(gh pr view $PR_NUMBER --json state --jq ".state")" - if [[ "$PR_STATE" == "OPEN" ]]; then - tell "Found open PR for release/$VERSION at $PR_URL, please wait for it to be merged before running this command again." - exit 1 - elif [[ "$PR_STATE" == "MERGED" ]]; then - tell "Found merged PR for release/$VERSION at $PR_URL, I will now look for a release tagged '$VERSION'" - RELEASE_URL="$(gh release view $VERSION --json url --jq ".url")" - if [[ "$RELEASE_URL" == "release not found" ]]; then - tell "No release found for $VERSION, I will publish it now" - publish-gh-release - else - tell "I already found a release for version $VERSION at $RELEASE_URL" - tell "I will now proceed to check the CHaP and Metatheory PRs" - exit 1 - fi - elif [[ "$PR_STATE" == "CLOSED" ]]; then - tell "Found closed PR for release/$VERSION at $PR_UR, you might want to re-open it" - exit 1 + + echo "4 Open and merge a new Plutus Update PR in plutus-tx-template" + PR_URL=$(get-pr-url IntersectMBO/plutus-tx-template "bump-plutus-$VERSION") + PR_STATE=$(get-pr-state "IntersectMBO/plutus-tx-template" "bump-plutus-$VERSION") + if [[ $PR_STATE == "MERGED" ]]; then + echo "✅ PR $PR_STATE at $PR_URL" + else + echo "❌ PR $PR_STATE" + fi + + echo "5 Merge the original Release PR in plutus" + PR_URL=$(get-pr-url IntersectMBO/plutus "release/$VERSION") + PR_STATE=$(get-pr-state IntersectMBO/plutus "release/$VERSION") + if [[ $PR_STATE == "MERGED" ]]; then + echo "✅ PR $PR_STATE at $PR_URL" else - tell "Found PR for release/$VERSION at $PR_UR with unknown state '$PR_STATE', please double check" - exit 1 + echo "❌ PR $PR_STATE" + fi + + echo "6 Publish the release on GitHub" + local RELEASE_URL=$(gh release view $VERSION --json url --jq ".url" 2>&1) + if [[ $RELEASE_URL == "release not found" ]]; then + echo "❌ Release not found" + else + echo "✅ Release found at $RELEASE_URL" + fi + + echo "7 Deploy the Haddock site for the new release" + local HADDOCK_URL="https://plutus.cardano.intersectmbo.org/haddock/$VERSION/" + local CURL_STATE=$(curl -s -o /dev/null -w "%{http_code}\n" $HADDOCK_URL) + if [[ $CURL_STATE == "404" ]]; then + echo "❌ Haddock site not found at $HADDOCK_URL" + else + echo "✅ Haddock site found at $HADDOCK_URL" fi -else - tell "No PR found for release/$VERSION, I will start the release process" - create-release-pr -fi \ No newline at end of file + + echo "8 Deploy the Metatheory site for the new release" + local METATHEORY_URL="https://plutus.cardano.intersectmbo.org/metatheory/$VERSION/" + CURL_STATE=$(curl -s -o /dev/null -w "%{http_code}\n" $HADDOCK_URL) + if [[ $CURL_STATE == "404" ]]; then + echo "❌ Metatheory site not found at $METATHEORY_URL" + else + echo "✅ Metatheory site found at $METATHEORY_URL" + fi + + echo +} + + +if [ $# -lt 1 ]; then + print-usage + exit 1 +elif ! [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + tell "Invalid version '$1', expecting something like 1.42.0.0" + exit 1 +fi + + +VERSION=$1 + + +while true; do + STEP="$(ask "Type [1-8] to run the given step or press enter to see status: ")" + case $STEP in + "1") check-and-open-plutus-pr ;; + "2") check-plutus-pr-review-status ;; + "3") check-and-open-chap-pr ;; + "4") check-and-open-plutus-tx-pr ;; + "5") merge-plutus-pr ;; + "6") check-and-publish-gh-release ;; + "7") deploy-haddock-site ;; + "8") deploy-metatheory-site ;; + *) + echo + print-status + ;; + esac +done \ No newline at end of file From 18767f8b6d6f6cd9cea95946890e1246166d875f Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 8 Jan 2025 12:10:48 +0100 Subject: [PATCH 16/21] final --- scripts/interactive-release.sh | 60 ++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index 5a2c9735bda..b661bb46105 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -247,75 +247,79 @@ print-usage() { print-status() { - echo "1 Open a new Release PR in plutus" local PR_URL=$(get-pr-url IntersectMBO/plutus "release/$VERSION") - local PR_STATE=$(get-pr-state IntersectMBO/plutus "release/$VERSION") + local PR_STATE=$(get-pr-state IntersectMBO/plutus "release/$VERSION") if [[ $PR_STATE == "OPEN" || $PR_STATE == "MERGED" ]]; then - echo -e "✅ PR $PR_STATE at $PR_URL" + echo -e "[1] ✅ Open a new Release PR in plutus\n PR $PR_STATE at $PR_URL" else - echo "❌ PR $PR_STATE" - fi + echo -e "[1] ❌ Open a new Release PR in plutus\n PR $PR_STATE" + fi + echo - echo "2 Wait for CI checks, review and approve the Release PR in plutus, do not merge it yet" if [[ $PR_STATE == "OPEN" || $PR_STATE == "MERGED" ]]; then - echo "✅ PR $PR_STATE at $PR_URL" + echo -e "[2] ✅ Approve the Release PR in plutus, do not merge yet\n PR $PR_STATE at $PR_URL" else - echo "❌ PR $PR_STATE" + echo -e "[2] ❌ Approve the Release PR in plutus, do not merge yet\n PR $PR_STATE" fi + echo - echo "3 Open and merge a new Plutus Release PR in CHaP" PR_URL=$(get-pr-url IntersectMBO/cardano-haskell-packages "plutus-release/$VERSION") PR_STATE=$(get-pr-state IntersectMBO/cardano-haskell-packages "plutus-release/$VERSION") - if [[ $PR_STATE == "OPEN" || $PR_STATE == "MERGED" ]]; then - echo "✅ PR $PR_STATE at $PR_URL" + if [[ $PR_STATE == "MERGED" ]]; then + echo -e "[3] ✅ Open and merge a new Plutus Release PR in CHaP\n PR $PR_STATE at $PR_URL" + elif [[ $PR_STATE == "OPEN" ]]; then + echo -e "[3] ❌ Open and merge a new Plutus Release PR in CHaP\n PR $PR_STATE but not MERGED at $PR_URL" else - echo "❌ PR $PR_STATE" + echo -e "[3] ❌ Open and merge a new Plutus Release PR in CHaP\n PR $PR_STATE" fi + echo - echo "4 Open and merge a new Plutus Update PR in plutus-tx-template" PR_URL=$(get-pr-url IntersectMBO/plutus-tx-template "bump-plutus-$VERSION") PR_STATE=$(get-pr-state "IntersectMBO/plutus-tx-template" "bump-plutus-$VERSION") if [[ $PR_STATE == "MERGED" ]]; then - echo "✅ PR $PR_STATE at $PR_URL" + echo -e "[4] ✅ Open and merge a new Plutus Update PR in plutus-tx-template\n PR $PR_STATE at $PR_URL" + elif [[ $PR_STATE == "OPEN" ]]; then + echo -e "[4] ❌ Open and merge a new Plutus Update PR in plutus-tx-template\n PR $PR_STATE but not MERGED at $PR_URL" else - echo "❌ PR $PR_STATE" + echo -e "[4] ❌ Open and merge a new Plutus Update PR in plutus-tx-template\n PR $PR_STATE" fi + echo - echo "5 Merge the original Release PR in plutus" PR_URL=$(get-pr-url IntersectMBO/plutus "release/$VERSION") PR_STATE=$(get-pr-state IntersectMBO/plutus "release/$VERSION") if [[ $PR_STATE == "MERGED" ]]; then - echo "✅ PR $PR_STATE at $PR_URL" + echo -e "[5] ✅ Merge the original Release PR in plutus\n PR $PR_STATE at $PR_URL" + elif [[ $PR_STATE == "OPEN" ]]; then + echo -e "[5] ❌ Merge the original Release PR in plutus\n PR $PR_STATE but not MERGED at $PR_URL" else - echo "❌ PR $PR_STATE" + echo -e "[5] ❌ Merge the original Release PR in plutus\n PR $PR_STATE at $PR_URL" fi + echo - echo "6 Publish the release on GitHub" local RELEASE_URL=$(gh release view $VERSION --json url --jq ".url" 2>&1) if [[ $RELEASE_URL == "release not found" ]]; then - echo "❌ Release not found" + echo -e "[6] ❌ Publish the release on GitHub\n Release not found" else - echo "✅ Release found at $RELEASE_URL" + echo -e "[6] ✅ Publish the release on GitHub\n Release found at $RELEASE_URL" fi + echo - echo "7 Deploy the Haddock site for the new release" local HADDOCK_URL="https://plutus.cardano.intersectmbo.org/haddock/$VERSION/" local CURL_STATE=$(curl -s -o /dev/null -w "%{http_code}\n" $HADDOCK_URL) if [[ $CURL_STATE == "404" ]]; then - echo "❌ Haddock site not found at $HADDOCK_URL" + echo -e "[7] ❌ Deploy the Haddock site for the new release\n Haddock site not found at $HADDOCK_URL" else - echo "✅ Haddock site found at $HADDOCK_URL" + echo -e "[7] ✅ Deploy the Haddock site for the new release\n Haddock site found at $HADDOCK_URL" fi + echo - echo "8 Deploy the Metatheory site for the new release" local METATHEORY_URL="https://plutus.cardano.intersectmbo.org/metatheory/$VERSION/" CURL_STATE=$(curl -s -o /dev/null -w "%{http_code}\n" $HADDOCK_URL) if [[ $CURL_STATE == "404" ]]; then - echo "❌ Metatheory site not found at $METATHEORY_URL" + echo -e "[8] ❌ Deploy the Metatheory site for the new release\n Metatheory site not found at $METATHEORY_URL" else - echo "✅ Metatheory site found at $METATHEORY_URL" + echo -e "[8] ✅ Deploy the Metatheory site for the new release\n Metatheory site found at $METATHEORY_URL" fi - echo } From ca0ef7057e28b8a4ed72d9148728a45f8c5d722c Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 8 Jan 2025 12:18:51 +0100 Subject: [PATCH 17/21] wip --- scripts/interactive-release.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index b661bb46105..187a7e89e72 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -68,7 +68,7 @@ maybe-open-pr() { local PR_STATE=$(get-pr-state $REPO $BRANCH) if [[ -z $PR_NUMBER ]]; then - tell "No PR found with in $REPO with branch $BRANCH, I will create the PR" + tell "No PR found in $REPO with branch $BRANCH, I will create the PR" $COMMAND else case $PR_STATE in @@ -91,7 +91,7 @@ maybe-open-pr() { check-and-open-plutus-pr() { - maybe-open-pr IntersectMBO/plutus "release/$VERSION" open-plutus-pr + maybe-open-pr IntersectMBO/plutus release/$VERSION open-plutus-pr } @@ -127,9 +127,9 @@ open-plutus-pr() { popd > /dev/null done - cp ../.pre-commit-config.yaml .pre-commit-config.yaml + cp ../.pre-commit-config.yaml .pre-commit-config.yaml # this file is not in git so we need to copy it or pre-commit will complain git add . - pre-commit run cabal-fmt || true + pre-commit run cabal-fmt || true # pre-commit will fail but will modify the files in place, hence the second git add . below git add . git commit -m "Release $VERSION" || true git push --force --set-upstream origin $PR_BRANCH @@ -150,7 +150,7 @@ open-plutus-pr() { check-and-open-chap-pr() { - maybe-open-pr IntersectMBO/cardano-haskell-packages "plutus-release/$VERSION" open-chap-pr + maybe-open-pr IntersectMBO/cardano-haskell-packages plutus-release/$VERSION open-chap-pr } From ce6fc8499859a47cbdcebcbbd873e0e407ea8e27 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 9 Jan 2025 15:26:34 +0100 Subject: [PATCH 18/21] wip --- scripts/interactive-release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index 187a7e89e72..00f9a82b1f3 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -335,9 +335,9 @@ fi VERSION=$1 - +print-status while true; do - STEP="$(ask "Type [1-8] to run the given step or press enter to see status: ")" + STEP="$(ask "Type [1-8] to run the given step or press enter to see updated status: ")" case $STEP in "1") check-and-open-plutus-pr ;; "2") check-plutus-pr-review-status ;; From 2c27a5fbad6a81c7f1b1cbb3cedb99aa7c9d863b Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 13:40:50 +0100 Subject: [PATCH 19/21] wip --- scripts/interactive-release.sh | 57 ++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index 00f9a82b1f3..0cc80c7f193 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -58,6 +58,18 @@ get-pr-state() { } +get-pr-merge-state-status() { + local REPO=$1 + local BRANCH=$2 + local PR_NUMBER=$(get-pr-number $REPO $BRANCH) + if [[ -z $PR_NUMBER ]]; then + echo MISSING + else + gh pr view $PR_NUMBER --repo $REPO --json mergeStateStatus --jq ".mergeStateStatus" + fi +} + + maybe-open-pr() { local REPO=$1 local BRANCH=$2 @@ -210,7 +222,8 @@ check-and-open-plutus-tx-pr() { merge-plutus-pr() { - local A=1 + local PR_NUMBER=$(get-pr-number IntersectMBO/plutus "release/$VERSION") + gh pr merge $PR_NUMBER } @@ -256,11 +269,14 @@ print-status() { fi echo - if [[ $PR_STATE == "OPEN" || $PR_STATE == "MERGED" ]]; then - echo -e "[2] ✅ Approve the Release PR in plutus, do not merge yet\n PR $PR_STATE at $PR_URL" + local PR_MERGE_STATE_STATUS=$(get-pr-merge-state-status IntersectMBO/plutus "release/$VERSION") + if [[ $PR_STATE == "OPEN" && $PR_MERGE_STATE_STATUS == "MERGEABLE" || $PR_STATE == "MERGED" ]]; then + echo -e "[2] ✅ Approve the Release PR in plutus, check CI is green, do not merge yet\n PR $PR_STATE and merge status $PR_MERGE_STATE_STATUS at $PR_URL" + elif [[ $PR_STATE == "MISSING" ]]; then + echo -e "[2] ❌ Approve the Release PR in plutus, check CI is green, do not merge yet\n PR $PR_STATE" else - echo -e "[2] ❌ Approve the Release PR in plutus, do not merge yet\n PR $PR_STATE" - fi + echo -e "[2] ❌ Approve the Release PR in plutus, check CI is green, do not merge yet\n PR $PR_STATE and merge status $PR_MERGE_STATE_STATUS at $PR_URL" + fi echo PR_URL=$(get-pr-url IntersectMBO/cardano-haskell-packages "plutus-release/$VERSION") @@ -291,6 +307,8 @@ print-status() { echo -e "[5] ✅ Merge the original Release PR in plutus\n PR $PR_STATE at $PR_URL" elif [[ $PR_STATE == "OPEN" ]]; then echo -e "[5] ❌ Merge the original Release PR in plutus\n PR $PR_STATE but not MERGED at $PR_URL" + elif [[ $PR_STATE == "MISSING" ]]; then + echo -e "[5] ❌ Merge the original Release PR in plutus\n PR $PR_STATE" else echo -e "[5] ❌ Merge the original Release PR in plutus\n PR $PR_STATE at $PR_URL" fi @@ -324,21 +342,40 @@ print-status() { } +detect-old-version() { + local OLD_VERSION=$(grep "^version:" plutus-core/plutus-core.cabal) + echo ${OLD_VERSION##* } +} + + +compute-new-version() { + local OLD_VERSION=$1 + IFS='.' read -r MAJOR MINOR PATCH BUILD <<< $OLD_VERSION + MINOR=$((MINOR + 1)) + echo "$MAJOR.$MINOR.$PATCH.$BUILD" +} + + +VERSION= + + if [ $# -lt 1 ]; then - print-usage - exit 1 + OLD_VERSION=$(detect-old-version) + VERSION=$(compute-new-version $OLD_VERSION) + tell "No VERSION argument given, detected old version $OLD_VERSION, releasing new version $VERSION\n" elif ! [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then tell "Invalid version '$1', expecting something like 1.42.0.0" exit 1 +else + VERSION=$1 fi -VERSION=$1 - print-status while true; do - STEP="$(ask "Type [1-8] to run the given step or press enter to see updated status: ")" + STEP="$(ask "Type [1-8] to run the given step, 0/q/CTRL+C to exit, or press enter to see updated status: ")" case $STEP in + [0q]) exit 0 ;; "1") check-and-open-plutus-pr ;; "2") check-plutus-pr-review-status ;; "3") check-and-open-chap-pr ;; From 4f3ea3350a47d44122fe999f747248bad9118dd4 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 13:48:29 +0100 Subject: [PATCH 20/21] wi0 --- scripts/interactive-release.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index 0cc80c7f193..8cea8d4d41a 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -14,7 +14,7 @@ # Each of these steps depend on the previous one, so it's important to follow them in order. # Each step is idempotent, so you can run the script multiple times if needed. # -# Usage: ./scripts/interactive-release.sh VERSION +# Usage: ./scripts/interactive-release.sh [VERSION] set -euo pipefail @@ -179,6 +179,7 @@ open-chap-pr() { gh repo clone IntersectMBO/cardano-haskell-packages -- --single-branch --branch main cd cardano-haskell-packages git checkout -b $PR_BRANCH + tell "Running ./scripts/add-from-github.sh with COMMIT_SHA=$COMMIT_SHA" ./scripts/add-from-github.sh https://github.com/IntersectMBO/plutus $COMMIT_SHA plutus-core plutus-ledger-api plutus-tx plutus-tx-plugin git push --force --set-upstream origin $PR_BRANCH local PR_URL=$(gh pr create \ From 8229e3ae609a393197c7c1db42a19552bbcb98b8 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 13:52:21 +0100 Subject: [PATCH 21/21] wip --- scripts/interactive-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/interactive-release.sh b/scripts/interactive-release.sh index 8cea8d4d41a..67741a2b562 100755 --- a/scripts/interactive-release.sh +++ b/scripts/interactive-release.sh @@ -175,7 +175,7 @@ open-chap-pr() { local PR_BRANCH="plutus-release/$VERSION" rm -rf cardano-haskell-packages || true git fetch --tags - local COMMIT_SHA=$(git rev-parse --verify --quiet $VERSION) + local COMMIT_SHA=$(git rev-parse --verify --quiet "release/$VERSION") gh repo clone IntersectMBO/cardano-haskell-packages -- --single-branch --branch main cd cardano-haskell-packages git checkout -b $PR_BRANCH