forked from denoland/deno_core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add workflow to create a release
- Loading branch information
1 parent
f0ce429
commit b8f4a59
Showing
4 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: version_bump | ||
|
||
jobs: | ||
build: | ||
name: version bump | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 30 | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: full | ||
RUSTC_FORCE_INCREMENTAL: 1 | ||
|
||
steps: | ||
- name: Configure git | ||
run: | | ||
git config --global core.symlinks true | ||
git config --global fetch.parallel 32 | ||
- name: Clone repository | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.DENOBOT_PAT }} | ||
submodules: recursive | ||
|
||
- uses: denoland/setup-deno@v1 | ||
- uses: dsherret/rust-toolchain-file@v1 | ||
|
||
- name: Create PR for release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.DENOBOT_PAT }} | ||
GH_WORKFLOW_ACTOR: ${{ github.actor }} | ||
run: | | ||
git remote add upstream https://github.com/denoland/deno | ||
git config user.email "${{ github.actor }}@users.noreply.github.com" | ||
git config user.name "${{ github.actor }}" | ||
./tools/create_pr_for_release.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env -S deno run -A --lock=tools/deno.lock.json | ||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. | ||
import { DenoWorkspace } from "./deno_core_workspace.ts"; | ||
import { $, createOctoKit, getGitHubRepository } from "./deps.ts"; | ||
|
||
const octoKit = createOctoKit(); | ||
const workspace = await DenoWorkspace.load(); | ||
const repo = workspace.repo; | ||
const denoCoreCrate = workspace.getDenoCoreCrate(); | ||
|
||
// increment the core version | ||
await denoCoreCrate.increment("minor"); | ||
|
||
// increment the dependency crate versions | ||
for (const crate of workspace.getDenoCoreDependencyCrates()) { | ||
await crate.increment("minor"); | ||
} | ||
|
||
// update the lock file | ||
await workspace.getDenoCoreCrate().cargoUpdate("--workspace"); | ||
|
||
const originalBranch = await repo.gitCurrentBranch(); | ||
const newBranchName = `release_${denoCoreCrate.version.replace(/\./, "_")}`; | ||
|
||
// Create and push branch | ||
$.logStep(`Creating branch ${newBranchName}...`); | ||
await repo.gitBranch(newBranchName); | ||
await repo.gitAdd(); | ||
await repo.gitCommit(denoCoreCrate.version); | ||
$.logStep("Pushing branch..."); | ||
await repo.gitPush("-u", "origin", "HEAD"); | ||
|
||
// Open PR | ||
$.logStep("Opening PR..."); | ||
const openedPr = await octoKit.request("POST /repos/{owner}/{repo}/pulls", { | ||
...getGitHubRepository(), | ||
base: originalBranch, | ||
head: newBranchName, | ||
draft: false, | ||
title: denoCoreCrate.version, | ||
body: getPrBody(), | ||
}); | ||
$.log(`Opened PR at ${openedPr.data.url}`); | ||
|
||
function getPrBody() { | ||
let text = `Bumped versions for ${denoCoreCrate.version}\n\n` + | ||
`Please ensure:\n` + | ||
`- [ ] Crate versions are bumped correctly\n` + | ||
`To make edits to this PR:\n` + | ||
"```shell\n" + | ||
`git fetch upstream ${newBranchName} && git checkout -b ${newBranchName} upstream/${newBranchName}\n` + | ||
"```\n"; | ||
|
||
const actor = Deno.env.get("GH_WORKFLOW_ACTOR"); | ||
if (actor != null) { | ||
text += `\ncc @${actor}`; | ||
} | ||
|
||
return text; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. | ||
|
||
import { $, Repo } from "./deps.ts"; | ||
|
||
export class DenoWorkspace { | ||
#repo: Repo; | ||
|
||
static get rootDirPath() { | ||
const currentDirPath = $.path.dirname($.path.fromFileUrl(import.meta.url)); | ||
return $.path.resolve(currentDirPath, "../"); | ||
} | ||
|
||
static async load(): Promise<DenoWorkspace> { | ||
return new DenoWorkspace( | ||
await Repo.load({ | ||
name: "deno_core", | ||
path: DenoWorkspace.rootDirPath, | ||
}), | ||
); | ||
} | ||
|
||
private constructor(repo: Repo) { | ||
this.#repo = repo; | ||
} | ||
|
||
get repo() { | ||
return this.#repo; | ||
} | ||
|
||
get crates() { | ||
return this.#repo.crates; | ||
} | ||
|
||
/** Gets the deno_core dependency crates that should be published. */ | ||
getDenoCoreDependencyCrates() { | ||
return this.getDenoCoreCrate() | ||
.descendantDependenciesInRepo(); | ||
} | ||
|
||
getDenoCoreCrate() { | ||
return this.getCrate("deno_core"); | ||
} | ||
|
||
getCrate(name: string) { | ||
return this.#repo.getCrate(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. | ||
|
||
export * from "https://raw.githubusercontent.com/denoland/automation/0.19.0/mod.ts"; | ||
export * from "https://raw.githubusercontent.com/denoland/automation/0.19.0/github_actions.ts"; |