From 1ee23f469bca205f75a920ca5c9803d15b306094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Tue, 4 Jun 2024 16:45:19 -0700 Subject: [PATCH 1/2] take pre-releases into consideration --- tools/update/main.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/update/main.ts b/tools/update/main.ts index 43d7d78cd8..3b55a08b47 100644 --- a/tools/update/main.ts +++ b/tools/update/main.ts @@ -232,11 +232,20 @@ class Updater { async fetchLatestReleaseTagName(fullRepoName: string): Promise { try { const [owner, repoName] = fullRepoName.split('/') - const release = await this.octokit.rest.repos.getLatestRelease({ + // Heuristic: Fetch as many releases on the first page as possible, + // and find the latest release by sorting the releases by semver + const releases = await this.octokit.rest.repos.listReleases({ owner, repo: repoName, + per_page: 100 }) - return release.data.tag_name + const release = releases.data.sort((a, b) => { + return a.created_at.localeCompare(b.created_at) + }).pop() + if (release === undefined) { + return null + } + return release.tag_name } catch (e) { if (e instanceof RequestError) { if (e.status === 404) { From af0eb62f1a6de5aea4acac2d6d76c9c8b9b17ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Tue, 4 Jun 2024 16:52:30 -0700 Subject: [PATCH 2/2] update docs --- tools/update/README.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tools/update/README.md b/tools/update/README.md index f3b3f67721..048769aba9 100644 --- a/tools/update/README.md +++ b/tools/update/README.md @@ -51,10 +51,11 @@ Above will update the rest of the dependencies to: - flow-go-sdk `v0.31.0` - flow-go `v0.26.0` -Instead of the version, it is also possible to provide a commit id. +Instead of the version, it is also possible to provide a commit, +in Go's expected format, i.e. the first 12 characters of the commit hash. ```sh -GH_TOKEN=`gh auth token` ts-node main.ts update --version v0.30.0 --versions onflow/flow-go@ +GH_TOKEN=`gh auth token` ts-node main.ts update --version v0.30.0 --versions onflow/flow-go@ ``` #### Configuring dependencies @@ -195,20 +196,15 @@ Go to the link that is shown at the end to create a new GitHub (pre-)release for Once the GitHub release has been published, re-run the `update` subcommand. The tool will determine that the next dependency needs to be updated. -> [!NOTE] -> The update tool only considers proper releases (i.e. not pre-releases)! (this is a GitHub API limitation) -> -> When updating to pre-releases, the version of a downstream has to be specified manually! This is not needed normally. - Versions are specified using the `--versions` flag, comma-separated. ```shell GH_TOKEN=`gh auth token` ts-node main.ts update \ - --version v1.0.0-M8 \ - --versions onflow/flow-go-sdk@v1.0.0-M5 + --version v1.0.0-M8 ``` -Again, the tool will determine the next downstream dependency that needs to get updated. This time is the `lint` module in the `onflow/cadence-tools` repo. +Again, the tool will determine the next downstream dependency that needs to get updated. +This time is the `lint` module in the `onflow/cadence-tools` repo.
@@ -266,14 +262,14 @@ Checking repo onflow/cadence-tools ... - Some downstream dependencies, like `flow-go`, are not tagged/released. - Use the latest commit instead. + Use the latest commit instead, in Go's expected format, i.e. the first 12 characters of the commit hash. For example, to `flow-emulator` depends on `flow-go`, and it can be updated using: ```shell $ GH_TOKEN=`gh auth token` ts-node main.ts update \ --version v1.0.0-M8 \ - --versions onflow/flow-go-sdk@v1.0.0-M5,onflow/cadence-tools/lint@v1.0.0-M5,onflow/flow-go@3677206d445c + --versions onflow/flow-go@3677206d445c ``` - Some downstream dependencies are modules in the same repo.