From 9085ea5d72f034a72f286c3abf727342a25978a4 Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Wed, 12 Jan 2022 15:02:46 -0500 Subject: [PATCH 1/5] Update automation --- README.md | 12 +++++++++ gh_pages_commit_input.json | 7 ++++++ script/release | 51 +++++++++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 gh_pages_commit_input.json diff --git a/README.md b/README.md index b772c7e2..4187339b 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,18 @@ See [all releases](https://github.com/github/pages-gem/releases). To release a new version of this gem, run `script/release` from the `master` branch. +This will create and tag the release. + +It will also create prs in the relevant repos and assign them to you. It is your responsibility to + +1. update the version of the gem in those repos +2. deploy those services as needed + +The relevant repos are: +1. [github-pages](https://github.com/github/pages) +2. [jekyll-build-pages](https://github.com/actions/jekyll-build-pages/blob/main/Gemfile) +3. [pages.github.com](https://github.com/github/pages.github.com) + ## License Distributed under the [MIT License](LICENSE). diff --git a/gh_pages_commit_input.json b/gh_pages_commit_input.json new file mode 100644 index 00000000..dfdfbc50 --- /dev/null +++ b/gh_pages_commit_input.json @@ -0,0 +1,7 @@ +{ + "tree": "8e473762f00cab18744b90f7d32557410e549869", + "parents": [ + "cd957f6dab7a16078dbcb08576d7b60214192f43" + ], + "message": "automated commit for pr creation" +} \ No newline at end of file diff --git a/script/release b/script/release index a67084b9..54ba1042 100755 --- a/script/release +++ b/script/release @@ -39,4 +39,53 @@ git fetch -t origin # Tag it and bag it. gem push github-pages-*.gem && git tag "$tag" && - git push origin master && git push origin "$tag" +git push origin master && git push origin "$tag" + +# create a new release on github +gh release create "$tag" --notes "Automated release for $tag" + +#for each dependent repo, create a new branch an a blank pr. +# first get the sha of main for each repo + +gh_pages_sha = gh api repos/github/pages/git/refs/heads/master | jq '. | .object.sha' +jekyll_sha = gh api repos/actions/jekyll-build-pages/git/refs/heads/main | jq '. | .object.sha' +gh_pages_site_sha = gh api repos/github/pages.github.com/git/refs/heads/master | jq '. | .object.sha' + +# then create the branches + +gh api repos/github/pages/git/refs -F "sha"="$gh_pages_sha" -F "ref"="refs/heads/pages-gem-release-$tag" +gh api repos/github/pages/git/refs -F "sha"="$jekyll_sha" -F "ref"="refs/heads/pages-gem-release-$tag" +gh api repos/github/pages/git/refs -F "sha"="$gh_pages_site_sha" -F "ref"="refs/heads/pages-gem-release-$tag" + +#then we need the tree object so we can create a commit using the api + +gh_pages_tree = gh api repos/github/pages/git/commits/$gh_pages_sha | jq '. | .tree.sha' +jekyll_tree = gh api repos/github/actions/jekyll-build-pages/commits/$jekyll_sha | jq '. | .tree.sha' +gh_pages_site_tree = gh api repos/github/papages.github.comges/git/commits/$gh_pages_site_sha | jq '. | .tree.sha' + +# create the input file for the commit. We have to do this because the F flag doesn't support arrays + +echo "{\"tree\": \"$gh_pages_tree\", \"parents\": [\"$gh_pages_sha\"], \"message\": \"automated commit for pr creation\"}" > gh_pages_commit_input.json +echo "{\"tree\": \"$jekyll_tree\", \"parents\": [\"$jekyll_sha\"], \"message\": \"automated commit for pr creation\"}" > jekyll_commit_input.json +echo "{\"tree\": \"$gh_pages_site_tree\", \"parents\": [\"$gh_pages_site_sha\"], \"message\": \"automated commit for pr creation\"}" > gh_pages_site_commit_input.json + +# create the commit + +new_gh_pages_sha = gh api repos/github/pages/git/commits --input gh_pages_commit_input.json | jq '. | .sha' +new_jekyll_sha = gh api repos/actions/jekyll-build-pages/git/commits --input jekyll_commit_input.json | jq '. | .sha' +new_gh_pages_site_sha = gh api repos/github/pages.github.com/git/commits --input gh_pages_site_commit_input.json | jq '. | .sha' + +# associate the commit with the branch + +gh api repos/github/pages/git/refs/heads/pages-gem-release-$tag -F "sha"="$new_gh_pages_sha" -F "ref"="refs/heads/pages-gem-release-$tag" -F "force"="true" +gh api repos/actions/jekyll-build-pages/git/refs/heads/pages-gem-release-$tag -F "sha"="$new_jekyll_sha" -F "ref"="refs/heads/pages-gem-release-$tag" -F "force"="true" +gh api repos/github/pages.github.com/git/refs/heads/pages-gem-release-$tag -F "sha"="$new_gh_pages_site_sha" -F "ref"="refs/heads/pages-gem-release-$tag" -F "force"="true" + +# create pull requests in downstream repos +gh pr create --base "master" --reviewer "@me" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "github/pages" +gh pr create --base "main" --reviewer "@me" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "actions/jekyll-build-pages" +gh pr create --base "master" --reviewer "@me" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "github/pages.github.com" + +# clean up the input file for the commit + +rm gh_pages_commit_input.json jekyll_commit_input.json gh_pages_site_commit_input.json \ No newline at end of file From bbb55f25c18f2cff330b3be4634d76e225dd84a9 Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Wed, 12 Jan 2022 15:20:06 -0500 Subject: [PATCH 2/5] remove bad file, other updates --- gh_pages_commit_input.json | 7 ------- script/release | 6 +++--- 2 files changed, 3 insertions(+), 10 deletions(-) delete mode 100644 gh_pages_commit_input.json diff --git a/gh_pages_commit_input.json b/gh_pages_commit_input.json deleted file mode 100644 index dfdfbc50..00000000 --- a/gh_pages_commit_input.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "tree": "8e473762f00cab18744b90f7d32557410e549869", - "parents": [ - "cd957f6dab7a16078dbcb08576d7b60214192f43" - ], - "message": "automated commit for pr creation" -} \ No newline at end of file diff --git a/script/release b/script/release index 54ba1042..fbf19bab 100755 --- a/script/release +++ b/script/release @@ -82,9 +82,9 @@ gh api repos/actions/jekyll-build-pages/git/refs/heads/pages-gem-release-$tag -F gh api repos/github/pages.github.com/git/refs/heads/pages-gem-release-$tag -F "sha"="$new_gh_pages_site_sha" -F "ref"="refs/heads/pages-gem-release-$tag" -F "force"="true" # create pull requests in downstream repos -gh pr create --base "master" --reviewer "@me" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "github/pages" -gh pr create --base "main" --reviewer "@me" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "actions/jekyll-build-pages" -gh pr create --base "master" --reviewer "@me" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "github/pages.github.com" +gh pr create --base "master" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "github/pages" +gh pr create --base "main" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "actions/jekyll-build-pages" +gh pr create --base "master" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "github/pages.github.com" # clean up the input file for the commit From faaabf3f112cb88666be218f7ea6e32ed830d494 Mon Sep 17 00:00:00 2001 From: Felipe Suero <85468376+felipesu19@users.noreply.github.com> Date: Thu, 13 Jan 2022 07:20:05 -0500 Subject: [PATCH 3/5] Update script/release Co-authored-by: Tommy Byrd --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index fbf19bab..6dbbee32 100755 --- a/script/release +++ b/script/release @@ -61,7 +61,7 @@ gh api repos/github/pages/git/refs -F "sha"="$gh_pages_site_sha" -F "ref"="refs/ gh_pages_tree = gh api repos/github/pages/git/commits/$gh_pages_sha | jq '. | .tree.sha' jekyll_tree = gh api repos/github/actions/jekyll-build-pages/commits/$jekyll_sha | jq '. | .tree.sha' -gh_pages_site_tree = gh api repos/github/papages.github.comges/git/commits/$gh_pages_site_sha | jq '. | .tree.sha' +gh_pages_site_tree = gh api repos/github/pages.github.com/git/commits/$gh_pages_site_sha | jq '. | .tree.sha' # create the input file for the commit. We have to do this because the F flag doesn't support arrays From 2a4a405a22b59919daee8ce0c036fe72f9c1b4db Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Thu, 13 Jan 2022 07:37:10 -0500 Subject: [PATCH 4/5] Incorporate Feedback --- .gitignore | 3 ++- script/release | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 3e7dd427..1b85dd91 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .sass-cache CNAME test-site/ -vendor/ \ No newline at end of file +vendor/ +tmp/ \ No newline at end of file diff --git a/script/release b/script/release index fbf19bab..cf5f6fda 100755 --- a/script/release +++ b/script/release @@ -1,4 +1,9 @@ #!/bin/sh + +# check that gh is installed and logged in + +gh auth status -h github.com + # Tag and push a release. set -e @@ -44,6 +49,10 @@ git push origin master && git push origin "$tag" # create a new release on github gh release create "$tag" --notes "Automated release for $tag" + +# create a tmp folder +mkdir -p tmp + #for each dependent repo, create a new branch an a blank pr. # first get the sha of main for each repo @@ -61,19 +70,19 @@ gh api repos/github/pages/git/refs -F "sha"="$gh_pages_site_sha" -F "ref"="refs/ gh_pages_tree = gh api repos/github/pages/git/commits/$gh_pages_sha | jq '. | .tree.sha' jekyll_tree = gh api repos/github/actions/jekyll-build-pages/commits/$jekyll_sha | jq '. | .tree.sha' -gh_pages_site_tree = gh api repos/github/papages.github.comges/git/commits/$gh_pages_site_sha | jq '. | .tree.sha' +gh_pages_site_tree = gh api repos/github/pages.github.com/git/commits/$gh_pages_site_sha | jq '. | .tree.sha' # create the input file for the commit. We have to do this because the F flag doesn't support arrays -echo "{\"tree\": \"$gh_pages_tree\", \"parents\": [\"$gh_pages_sha\"], \"message\": \"automated commit for pr creation\"}" > gh_pages_commit_input.json -echo "{\"tree\": \"$jekyll_tree\", \"parents\": [\"$jekyll_sha\"], \"message\": \"automated commit for pr creation\"}" > jekyll_commit_input.json -echo "{\"tree\": \"$gh_pages_site_tree\", \"parents\": [\"$gh_pages_site_sha\"], \"message\": \"automated commit for pr creation\"}" > gh_pages_site_commit_input.json +echo "{\"tree\": \"$gh_pages_tree\", \"parents\": [\"$gh_pages_sha\"], \"message\": \"automated commit for pr creation\"}" > tmp/h_pages_commit_input.json +echo "{\"tree\": \"$jekyll_tree\", \"parents\": [\"$jekyll_sha\"], \"message\": \"automated commit for pr creation\"}" > tmp/jekyll_commit_input.json +echo "{\"tree\": \"$gh_pages_site_tree\", \"parents\": [\"$gh_pages_site_sha\"], \"message\": \"automated commit for pr creation\"}" > tmp/gh_pages_site_commit_input.json # create the commit -new_gh_pages_sha = gh api repos/github/pages/git/commits --input gh_pages_commit_input.json | jq '. | .sha' -new_jekyll_sha = gh api repos/actions/jekyll-build-pages/git/commits --input jekyll_commit_input.json | jq '. | .sha' -new_gh_pages_site_sha = gh api repos/github/pages.github.com/git/commits --input gh_pages_site_commit_input.json | jq '. | .sha' +new_gh_pages_sha = gh api repos/github/pages/git/commits --input tmp/gh_pages_commit_input.json | jq '. | .sha' +new_jekyll_sha = gh api repos/actions/jekyll-build-pages/git/commits --input tmp/jekyll_commit_input.json | jq '. | .sha' +new_gh_pages_site_sha = gh api repos/github/pages.github.com/git/commits --input tmp/gh_pages_site_commit_input.json | jq '. | .sha' # associate the commit with the branch @@ -88,4 +97,4 @@ gh pr create --base "master" --head "pages-gem-release-$tag" --title "Bump pages # clean up the input file for the commit -rm gh_pages_commit_input.json jekyll_commit_input.json gh_pages_site_commit_input.json \ No newline at end of file +rm tmp/* \ No newline at end of file From dc5a93a3d4930bd21323bfdcd19013b0b6a6aa0a Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Fri, 14 Jan 2022 12:40:58 -0500 Subject: [PATCH 5/5] Removed unneeded dependency --- script/release | 7 ------- 1 file changed, 7 deletions(-) diff --git a/script/release b/script/release index cf5f6fda..2384d768 100755 --- a/script/release +++ b/script/release @@ -58,42 +58,35 @@ mkdir -p tmp gh_pages_sha = gh api repos/github/pages/git/refs/heads/master | jq '. | .object.sha' jekyll_sha = gh api repos/actions/jekyll-build-pages/git/refs/heads/main | jq '. | .object.sha' -gh_pages_site_sha = gh api repos/github/pages.github.com/git/refs/heads/master | jq '. | .object.sha' # then create the branches gh api repos/github/pages/git/refs -F "sha"="$gh_pages_sha" -F "ref"="refs/heads/pages-gem-release-$tag" gh api repos/github/pages/git/refs -F "sha"="$jekyll_sha" -F "ref"="refs/heads/pages-gem-release-$tag" -gh api repos/github/pages/git/refs -F "sha"="$gh_pages_site_sha" -F "ref"="refs/heads/pages-gem-release-$tag" #then we need the tree object so we can create a commit using the api gh_pages_tree = gh api repos/github/pages/git/commits/$gh_pages_sha | jq '. | .tree.sha' jekyll_tree = gh api repos/github/actions/jekyll-build-pages/commits/$jekyll_sha | jq '. | .tree.sha' -gh_pages_site_tree = gh api repos/github/pages.github.com/git/commits/$gh_pages_site_sha | jq '. | .tree.sha' # create the input file for the commit. We have to do this because the F flag doesn't support arrays echo "{\"tree\": \"$gh_pages_tree\", \"parents\": [\"$gh_pages_sha\"], \"message\": \"automated commit for pr creation\"}" > tmp/h_pages_commit_input.json echo "{\"tree\": \"$jekyll_tree\", \"parents\": [\"$jekyll_sha\"], \"message\": \"automated commit for pr creation\"}" > tmp/jekyll_commit_input.json -echo "{\"tree\": \"$gh_pages_site_tree\", \"parents\": [\"$gh_pages_site_sha\"], \"message\": \"automated commit for pr creation\"}" > tmp/gh_pages_site_commit_input.json # create the commit new_gh_pages_sha = gh api repos/github/pages/git/commits --input tmp/gh_pages_commit_input.json | jq '. | .sha' new_jekyll_sha = gh api repos/actions/jekyll-build-pages/git/commits --input tmp/jekyll_commit_input.json | jq '. | .sha' -new_gh_pages_site_sha = gh api repos/github/pages.github.com/git/commits --input tmp/gh_pages_site_commit_input.json | jq '. | .sha' # associate the commit with the branch gh api repos/github/pages/git/refs/heads/pages-gem-release-$tag -F "sha"="$new_gh_pages_sha" -F "ref"="refs/heads/pages-gem-release-$tag" -F "force"="true" gh api repos/actions/jekyll-build-pages/git/refs/heads/pages-gem-release-$tag -F "sha"="$new_jekyll_sha" -F "ref"="refs/heads/pages-gem-release-$tag" -F "force"="true" -gh api repos/github/pages.github.com/git/refs/heads/pages-gem-release-$tag -F "sha"="$new_gh_pages_site_sha" -F "ref"="refs/heads/pages-gem-release-$tag" -F "force"="true" # create pull requests in downstream repos gh pr create --base "master" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "github/pages" gh pr create --base "main" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "actions/jekyll-build-pages" -gh pr create --base "master" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "github/pages.github.com" # clean up the input file for the commit