Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update automation #812

Merged
merged 6 commits into from Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -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).
51 changes: 50 additions & 1 deletion script/release
Expand Up @@ -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"
felipesu19 marked this conversation as resolved.
Show resolved Hide resolved

#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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What shell are you using? I thought you'd need backticks to execute commands and return their output.

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'
felipesu19 marked this conversation as resolved.
Show resolved Hide resolved

# 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
felipesu19 marked this conversation as resolved.
Show resolved Hide resolved
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" --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

rm gh_pages_commit_input.json jekyll_commit_input.json gh_pages_site_commit_input.json