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

ci: autogenerate release #269

Closed
wants to merge 17 commits into from
Closed

Conversation

shawnyu5
Copy link
Contributor

@shawnyu5 shawnyu5 commented Feb 23, 2023

Closes #249

A GitHub actions to auto-generate a release tag upon the push of a new tag

New release tags should be generated using npm version major | minor | patch, and hence should adhere to the format of v* (v0.1.2). This action will only work with tags prepended with v

This CI job should not enforce all CI should pass before creating a new release. That decision should be on the person creating the release to decide.

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

Did you also want to copy what I do in https://github.com/DevelopingSpace/starchart/blob/main/.github/workflows/ci.yaml#L311-L353 and have it also build and push a production image? You'd probably use type=semver for this, and also bump latest and main

.github/workflows/release.yaml Outdated Show resolved Hide resolved
.github/workflows/release.yaml Show resolved Hide resolved
@@ -30,3 +27,42 @@ jobs:
# generate release name with the tag name that was just pushed
automatic_release_tag: ${{ steps.vars.outputs.tag }}
prerelease: false
Docker-Build:
# We'll only build and push when landing on main, not for PRs
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this, since we'll never run this in response to a PR, right (only on tag)?

flavor: latest=true
tags: |
type=semver,value=${{ steps.vars.outputs.tag }}
- name: Log in to the GitHub Container Registry
Copy link
Contributor

Choose a reason for hiding this comment

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

Blank line in between all steps, or none, but be consistent.

.github/workflows/release.yaml Show resolved Hide resolved
permissions:
actions: write
contents: write
pull-requests: write
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you educate me on this. Why are these last 2 required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still need to mess around with those permissions. The github action to generate a tag needs some permissions to save the tag in the repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would we not push the tag ourselves? What is the workflow you imagine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, the gh action is used to generate the release when a tag is pushed. With default permissions given in a workflow, I get this error, that it doesnt have enough permissions to publish a new release

https://github.com/shawnyu5/starchart/actions/runs/4249711991/jobs/7390117298

Copy link
Contributor

Choose a reason for hiding this comment

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

That error makes it seem like it wants to create a new tag, which seems odd if we push our own.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think its trying to generate the release. There seems to be a distinction between "release tags" and "git tags"?

Git tags

release tags

Im not sure If I fully understand this yet tbh...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're right, and this is something I didn't fully understand. I found this helpful:

9.6.1
Tags and releases—the differences
Well a tag is just a unique symbolic name attached to a particular commit point. Git supports two types of tag (§ 6.3.4) a lightweight tag (without a message) and an annotated tag (with a message). In Brackets we only have lightweight tags.

GitHub can display both. In Figure 9.82 above, the tags are all lightweight, I can tell this because it tells me there is no release notes for any of the tags, this release note is what Git refers to as the tag message attached to the annotated tag. If we added a release note it would become an annotated tag.

A release on the other hand is a GitHub object, it is still attached to a particular commit point, but this time it allows us to specify that a particular commit has a particular release status.

GitHub converts all our tags to releases when we push them up from the local repository and that is why they are listed as both releases and tags.

So GitHub does want our manually created tag, and will use it to create a new GitHub Release (tag) object, which is why it wants elevated privileges.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah that makes sense. Tho I don't think it needs all those permissions there, I just put them there for now so I can move on to test the rest of the action. I should remove the ones the action does not need.

@SerpentBytes
Copy link
Contributor

@shawnyu5, just checking in to see if you are still working on this PR.

@SerpentBytes SerpentBytes self-assigned this Mar 21, 2023
@Eakam1007 Eakam1007 removed this from the Milestone 0.7 milestone Mar 26, 2023
@Eakam1007 Eakam1007 added this to the Milestone 0.8 milestone Mar 26, 2023
@SerpentBytes SerpentBytes mentioned this pull request Mar 27, 2023
@humphd
Copy link
Contributor

humphd commented Mar 30, 2023

Closing in favour of #466

@humphd humphd closed this Mar 30, 2023
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.

Automate release at the end of given milestone
5 participants