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

OSOE-735: Introduce versioning and releases #325

Merged
merged 37 commits into from
Mar 21, 2024
Merged

Conversation

davidpuplava
Copy link
Contributor

@davidpuplava davidpuplava commented Feb 9, 2024

OSOE-735
Fixes #284

EDIT:
Adding additional information to this summary based on the feedback from coderabbitai.

Regarding the spelling action, I've added a additional-pattern-include-list option to account for special cases such as referencing files directly from the dev branch.

Regarding alternate release process, the approach that we're taking here seems to be consistent with how other organizations version GitHub Actions. One difference is that well know actions such as actions/checkout are placed into their own repository. Considering how many different actions and workflows exist in LGHA, splitting them into different repositories is impractical, and not a very good developer experience.

Explanation of this Change

The process for version LGHA is as follows:

  1. Create a new release branch using the following convention release/v1.0 where the v1.0 is which every version you want to release.
  2. Push your release/v1.0 branch
  3. A new workflow tag-and-release will trigger based on the push of the release branch and perform the following steps.
  4. Automatically take the branch name release/v1.0 and remove the release/ to get the version tag v1.0
  5. Execute a new action set-gha-refs that will scan GitHub Actions and Workflows looking for @dev refs to update
  6. This new action will also look for generic patterns in the additional-pattern-include-list which allows for special considerations such as for the spelling action explicit file reference.
  7. The workflow and action files will be updated to use the new v1.0 reference.
  8. These file changes will automatically be committed to the release/v1.0
  9. A new v1.0 tag will be created.
  10. The branch and tag will be pushed to the repository
  11. The v1.0 tag will be --force pushed to the repo to update and existing tags that will now be outdated.

Security Considerations

The new tag-and-release workflow depends on a personal access token that should be configured in a secret named TAG_AND_RELEASE. This token is used in place of the default GITHUB_TOKEN that is typically used in workflows. The reason for this is because the token must have the workflow permission granted in order to push changes to GitHub Action files. By default, GITHUB_TOKEN does not have this permission.

…eate Workflow to automatically change refs and create a tag
Copy link
Contributor

coderabbitai bot commented Feb 9, 2024

Walkthrough

This update streamlines versioning and release management for GitHub Actions and Workflows. It introduces automation for setting specific references, tagging, and releasing to enhance deployment efficiency and version consistency across workflows, improving overall codebase reliability and maintainability.

Changes

File Path Change Summary
.github/actions/set-gha-refs/... Introduced scripts and actions to update GitHub Actions and Workflows references to a specified branch.
.github/workflows/tag-and-release.yml New workflow for automating tagging and releasing, including updating references and version management.
.github/workflows/tag-version-this-repo.yml,
.github/workflows/tag-version.yml
Added workflows for automating version tagging based on branch pushes, setting references, and ensuring proper workflow triggering.

Assessment against linked issues

Objective Addressed Explanation
Enable versioned usage of LGHA reusable workflows by introducing explicit releases like v1.0 and v1.1.
Implement tagging in Git for releases to replace current branch specifiers (@dev) automatically.
Establish special branches such as release/v1.0 for merging from dev and automate the process of replacing branch specifiers in commits, adding tags, and publishing releases on GitHub.
Address the specific considerations for the spelling action due to additional branch references. The spelling action considerations were not explicitly mentioned in the provided changes summary.
Explore alternative release processes while ensuring that tagging releases and subsequent automation are the primary goals. The exploration of alternative release processes is not clearly stated in the changes summary. Further details are needed to confirm if this objective is met.

Related issues

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

.github/actions/set-gha-refs/Set-Called-GHA-Refs.ps1 Outdated Show resolved Hide resolved
.github/actions/set-gha-refs/Set-Called-GHA-Refs.ps1 Outdated Show resolved Hide resolved
.github/actions/set-gha-refs/Set-Called-GHA-Refs.ps1 Outdated Show resolved Hide resolved
.github/actions/set-gha-refs/Set-Called-GHA-Refs.ps1 Outdated Show resolved Hide resolved
.github/workflows/tag-and-release.yml Outdated Show resolved Hide resolved
.github/workflows/tag-and-release.yml Outdated Show resolved Hide resolved
.github/actions/set-gha-refs/action.yml Outdated Show resolved Hide resolved
Copy link
Member

@BenedekFarkas BenedekFarkas left a comment

Choose a reason for hiding this comment

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

I tested this in a fork and tagging worked great!

Question: Shouldn't workflow/action references throughout the whole repo be updated? See this commit that was triggered by the release branch and created the tag.

For example, if I use a workflow from the v1.0 tag, then it will call other workflows and actions still from the dev branch.

.github/actions/set-gha-refs/action.yml Show resolved Hide resolved
.github/actions/set-gha-refs/action.yml Show resolved Hide resolved
.github/workflows/tag-version.yml Show resolved Hide resolved
.github/workflows/tag-version.yml Outdated Show resolved Hide resolved
.github/workflows/tag-version.yml Outdated Show resolved Hide resolved
.github/workflows/tag-version-this-repo.yml Show resolved Hide resolved
.github/workflows/tag-version.yml Show resolved Hide resolved
.github/workflows/tag-version.yml Outdated Show resolved Hide resolved
.github/workflows/tag-version.yml Show resolved Hide resolved
.github/actions/set-gha-refs/Set-Called-GHA-Refs.ps1 Outdated Show resolved Hide resolved
@BenedekFarkas
Copy link
Member

@davidpuplava just a reminder, see my review comments.

@davidpuplava
Copy link
Contributor Author

Thanks @BenedekFarkas - I will look at this today

Add inputs to tag-version workflow to pass to the set-gha-refs action.
This is similar to how LGHA's spelling workflow/action is done. This
then allows the tag-version-this-repo workflow to customize the
additional-pattern-include-list specific to LGHA explicit references.

This comment has been minimized.

@davidpuplava
Copy link
Contributor Author

@BenedekFarkas Question: Shouldn't workflow/action references throughout the whole repo be updated? See this commit that was triggered by the release branch and created the tag.

Yes, the reference should be updated in the entire repository. Let me try and replicate this by forking the repo and trying to create a release in my own remote.

I'll have to check but I think this might be because it's running in a fork. But it may no longer be an issue now that the action inputs were surfaced up to the calling workflows.

@davidpuplava
Copy link
Contributor Author

Ok, I believe I now have this working. I successfully created the release in my forked repo: https://github.com/davidpuplava/GitHub-Actions/releases/tag/v0.1.

I had to elevate the GITHUB_TOKEN to give it contents: write permission, but I don't think that is necessary in LGHA based on what I learned from past issues.

@BenedekFarkas
Copy link
Member

Ok, I believe I now have this working. I successfully created the release in my forked repo: https://github.com/davidpuplava/GitHub-Actions/releases/tag/v0.1.

I had to elevate the GITHUB_TOKEN to give it contents: write permission, but I don't think that is necessary in LGHA based on what I learned from past issues.

Are the other references updating for you (= in all actions/workflows pointing to Lombiq GitHub Actions stuff)? I see the spelling dictionary prefix updating for me too in my test repo, but none of the other stuff: https://github.com/BenedekFarkas/GitHub-Actions-OSOE-735-Test/commit/ae2421a415d28c8241b58587265d0cde6c496312

@davidpuplava
Copy link
Contributor Author

Are the other references updating for you (= in all actions/workflows pointing to Lombiq GitHub Actions stuff)? I see the spelling dictionary prefix updating for me too in my test repo, but none of the other stuff: https://github.com/BenedekFarkas/GitHub-Actions-OSOE-735-Test/commit/ae2421a415d28c8241b58587265d0cde6c496312

No, they were not updating for me. The only reference that was updating was the spelling dictionary reference. But I did figure out what was going on.

The Tag Version workflow uses a default value of the current repository's base URL as the "target" string to find called Workflows and Actions. For LGHA, this is Lombiq/GitHub-Actions, but for your forked repository it is BenedekFarkas/GitHub-Actions-OSOE-735-Test and for my forked repository it is davidpuplava/GitHubActions.

So in our forked repositories, nothing was matched because the Set GitHub Actions References action's Set-Called-GHA-Refs.ps1 script is matching using that base URL include list (i.e. looking for "uses: Lombiq/GitHub-Actions/..." in LGHA, but looking for "uses: BenedekFarkas/GitHub-Actions-OSOE-735-Test/..." in your fork).

To see this in action, in your repository, you can modify the Tag Version (this repo) workflow to use the called-repo-base-include-list input and pass in Lombiq/GitHub-Actions so that all the references get updated.

See an example of this in my forked copy here. I included both my repo base and LGHA repo base, and it updated all the corresponding GitHub Action calls accordingly in the automatic commit.

During testing in my forked copy, I noticed a bug with the regex used to get the Git reference, which I fixed in 05a109a.

I also fixed a typo in getting the line number for the matched/changed file, and I fixed in 4d5e3a8.

@BenedekFarkas
Copy link
Member

BenedekFarkas commented Mar 15, 2024

To see this in action, in your repository, you can modify the Tag Version (this repo) workflow to use the called-repo-base-include-list input and pass in Lombiq/GitHub-Actions so that all the references get updated.

Gotcha, that worked for me too, so it was PIBKAC! :D

What did you to make the github-actions[bot] user commit instead of your own?

BTW one thing I noticed is that specifying multiple repositories via the called-repo-base-include-list will upgrade them to the same version. That's intentional and "obvious", just calling this out because we can still use synchronized versioning for actions/workflows across different repositories, but in that case we have to make sure that a new version number is released across each affected repository.

@Piedone please check and resolve the threads above you started, if they're GTG.

@Piedone
Copy link
Member

Piedone commented Mar 18, 2024

I checked those two in the code, looks good!

@Piedone
Copy link
Member

Piedone commented Mar 21, 2024

Shouldn't this be merged now?

@BenedekFarkas
Copy link
Member

Yep, we're good to go - sorry @davidpuplava for the delay.

@BenedekFarkas BenedekFarkas added this pull request to the merge queue Mar 21, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 21, 2024
@BenedekFarkas BenedekFarkas added this pull request to the merge queue Mar 21, 2024
Merged via the queue into dev with commit 0f3e011 Mar 21, 2024
5 checks passed
@BenedekFarkas
Copy link
Member

And here's the first release, thanks @davidpuplava! https://github.com/Lombiq/GitHub-Actions/releases/tag/v1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce versioning and releases (OSOE-735)
3 participants