-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add major-minor-release workflow #45
Draft
s-weigand
wants to merge
8
commits into
pypa:unstable/v1
Choose a base branch
from
s-weigand:add-major-minor-releases
base: unstable/v1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e34653e
Add major-minor-release workflow
s-weigand b78d2e9
Use 'shell : python' instead of script
s-weigand 5baaafc
Applied requested changes
s-weigand 54e3ca6
Unnest outpust creation
s-weigand 5fbbe92
Make Tag pushing atomic
s-weigand 1ef704e
Split up git user setup, tag creation and tag pushing in separate tasks
s-weigand bf26813
Improved tag message
s-weigand aabe83c
Added sha of original commit to tag commit message
s-weigand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,62 @@ | ||||||||||||||||||
name: "Publish Major-Minor-Tags" | ||||||||||||||||||
on: | ||||||||||||||||||
push: | ||||||||||||||||||
tags: | ||||||||||||||||||
- "v*" | ||||||||||||||||||
|
||||||||||||||||||
jobs: | ||||||||||||||||||
push-tags: | ||||||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||||||
steps: | ||||||||||||||||||
- uses: actions/checkout@v2 | ||||||||||||||||||
- name: Set up Python 3.8 | ||||||||||||||||||
uses: actions/setup-python@v2 | ||||||||||||||||||
with: | ||||||||||||||||||
python-version: 3.8 | ||||||||||||||||||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it's time to bump this
Suggested change
|
||||||||||||||||||
- name: Install packaging | ||||||||||||||||||
run: python -m pip install -U packaging --user | ||||||||||||||||||
- name: Get versions | ||||||||||||||||||
id: get_versions | ||||||||||||||||||
shell: python | ||||||||||||||||||
run: | | ||||||||||||||||||
from packaging.version import parse | ||||||||||||||||||
|
||||||||||||||||||
tag_ref = "${{ github.ref }}" | ||||||||||||||||||
tag_name = tag_ref.split("/")[-1] | ||||||||||||||||||
version = parse(tag_name) | ||||||||||||||||||
print(f"tag_name: {tag_name}") | ||||||||||||||||||
print(f"version: {version}") | ||||||||||||||||||
if version.is_prerelease: | ||||||||||||||||||
print("No tags created (dev or pre version)!") | ||||||||||||||||||
exit(0) | ||||||||||||||||||
|
||||||||||||||||||
s-weigand marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
print("Creating new major and minor tags!") | ||||||||||||||||||
print(f"::set-output name=original_tag_name::{tag_name}") | ||||||||||||||||||
print(f"::set-output name=major_version::v{version.major}") | ||||||||||||||||||
print(f"::set-output name=minor_version::v{version.major}.{version.minor}") | ||||||||||||||||||
- name: Setup git user as [bot] | ||||||||||||||||||
run: | | ||||||||||||||||||
git config user.email 'github-actions[bot]@users.noreply.github.com' | ||||||||||||||||||
git config user.name 'github-actions[bot]' | ||||||||||||||||||
- name: Create major + minor tags | ||||||||||||||||||
if: steps.get_versions.outputs.original_tag_name != '' | ||||||||||||||||||
s-weigand marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
env: | ||||||||||||||||||
original_tag_name: ${{ steps.get_versions.outputs.original_tag_name }} | ||||||||||||||||||
major_version: ${{ steps.get_versions.outputs.major_version }} | ||||||||||||||||||
minor_version: ${{ steps.get_versions.outputs.minor_version }} | ||||||||||||||||||
run: | | ||||||||||||||||||
git tag --annotate '${{ env.major_version }}' \ | ||||||||||||||||||
--message='Major version tag of: ${{ env.original_tag_name }}' \ | ||||||||||||||||||
--message="Original tag SHA1: $(git rev-parse ${{ env.original_tag_name }})" | ||||||||||||||||||
git tag --annotate '${{ env.minor_version }}' \ | ||||||||||||||||||
--message='Minor version tag of: ${{ env.original_tag_name }}' \ | ||||||||||||||||||
--message="Original tag SHA1: $(git rev-parse ${{ env.original_tag_name }})" | ||||||||||||||||||
- name: Push major + minor tags | ||||||||||||||||||
if: steps.get_versions.outputs.original_tag_name != '' | ||||||||||||||||||
env: | ||||||||||||||||||
major_version: ${{ steps.get_versions.outputs.major_version }} | ||||||||||||||||||
minor_version: ${{ steps.get_versions.outputs.minor_version }} | ||||||||||||||||||
run: | | ||||||||||||||||||
git push --force --atomic origin \ | ||||||||||||||||||
'${{ env.major_version }}' \ | ||||||||||||||||||
'${{ env.minor_version }}' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I'm lately preferring the
create
event because it has closer semantics to what we're attempting to trigger. But using it requires a post-condition.WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly use
push
due to sheer habit, there were a lot fewer triggers (at least in the docs) when I started adopting gh-actions as soon as they came out of beta.The docs are kinda unclear on how to use it, would simply changing
push
forcreate
work? Or what is the proper pattern, only to trigger on tags that start withv
I guess semantically the closes would be to use
release
.I use this trigger for my actions and it works fine, but I'm not sure how this will play out with
dev
,pre
andpost
tags, since those will most likely not published.The other
release
type to use would becreated
, which wouldn't force one to release on the markedplace, but it could still happen by accident (I think to remember that the checkbox is checked by default after fist publishing).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage of
create
isIt's
(because it doesn't have "native" filters)
I usually create the tags using local Git and push them from CLI. And only after that I publish releases. So I'm not sure if
release
would be suitable. OTOH this workflow could auto-publish a release on tag creation. You already have a way of saying if the "pre-release" checkbox should be set.Also, I'm fine with publishing pre-releases to Marketplace. I've done it before.
See https://github.com/pypa/gh-action-pypi-publish/releases/tag/v1.0.0a0 — it has a pre-release checkbox. And it's marketplace page https://github.com/marketplace/actions/pypi-publish?version=v1.0.0a0 also has a pre-release marker, just like PyPI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think auto-publishing is a bit too much automation since the release messages often need some handcrafted work. e.g. markdown formatting, which can't be extracted from the tag.
As for the
published
event, I don't know how github determines what the current release is, my guess is that it sorts them by published date. If that assumption is correct apost
release could mess up what version is displayed on the marketplace. E.g. you have av2.0.0
release and after that releasev1.4.1.post0
to trigger the workflow,v1.4.1.post0
might be shown a current version. So IMHO[created, edited]
would be closer to the desired behavior.Also using
release
would make it more reasonable to add a link to the release to the created tags (see #45 (comment)).As for the semantics of
create
vs.push
, I think this boils down to different reference systemsremote
vs.locally
(sorry physics student here 😆 ).I personally prefer the more concise syntax of
push
, wheregives you the same functionality as
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the markdown part. First of all, it's possible to have tag annotations with markdown baked-in but I wouldn't care about it too much: when you mark a release as published to the Marketplace, the new version appears there but the release description does not show up there. Instead, it just contains README content.
So it's okay to just auto-publish and then, if needed, I'd just correct it.
FWIW we shouldn't care about ordering the tags: it'll be like this regardless of whether a robot or a human makes the release... And we're not going to avoid putting
.post
tags on the marketplace while moving the major tag there in Git.