Skip to content

Commit

Permalink
fix: ensure release tags are cronological (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored Oct 26, 2023
1 parent c3791c6 commit 2c5174f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The action does the following:
| publish_release | Whether or not to publish a release |
| publish_stable_release | Whether or not to publish a stable release. The opposite of `publish_pre_release`. |
| release_body | The body for the release |
| release_build | The build number to identify this build (i.e. first 7 characters of commit hash) |
| release_build | The build number to identify this build (i.e. `hhmmss`) |
| release_commit | The commit hash for the release |
| release_generate_release_notes | Whether or not to generate release notes for the release |
| release_tag | The tag for the release (i.e. `release_version`-`release_build`) |
Expand Down Expand Up @@ -110,7 +110,7 @@ subgraph "Set GitHub Outputs"
B4(changelog_url = '')
B5(changelog_version = '')
C1(release_build = \commit 0-7\)
C1(release_build = \hhmmss\)
C2(release_commit = \commit\ )
D1{GitHub Release Exists?}
Expand Down
18 changes: 12 additions & 6 deletions action/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,24 @@ def get_push_event_details() -> dict:
else:
return push_event_details

# use regex and convert created at to yyyy.m.d
match = re.search(r'(\d{4})-(\d{1,2})-(\d{1,2})', push_event["created_at"])
# use regex and convert created at to yyyy.m.d-hhmmss
# created_at: "2023-1-25T10:43:35Z"
match = re.search(r'(\d{4})-(\d{1,2})-(\d{1,2})T(\d{1,2}):(\d{2}):(\d{2})Z', push_event["created_at"])

release_version = ''
release_build = ''
if match:
year = match.group(1)
month = match.group(2).zfill(2) # Ensure month is zero-padded to two digits
day = match.group(3).zfill(2) # Ensure day is zero-padded to two digits
year = int(match.group(1))
month = int(match.group(2))
day = int(match.group(3))
hour = match.group(4).zfill(2)
minute = match.group(5).zfill(2)
second = match.group(6).zfill(2)
release_version = f"{year}.{month}.{day}"
release_build = f"{hour}{minute}{second}"

push_event_details['release_version'] = release_version
push_event_details['release_build'] = push_event["payload"]["head"][0:7]
push_event_details['release_build'] = release_build
return push_event_details


Expand Down

0 comments on commit 2c5174f

Please sign in to comment.