Skip to content

Commit

Permalink
Merge pull request #156 from crazy-max/prerelease-raw-pep440
Browse files Browse the repository at this point in the history
fix: handle raw statement for pep440 pre-release
  • Loading branch information
crazy-max committed Dec 6, 2021
2 parents 6d7c94a + aad230b commit e562237
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 8 deletions.
14 changes: 8 additions & 6 deletions README.md
Expand Up @@ -404,12 +404,13 @@ attribute.
| `v1.2.3` | `v{{major}}` | `v1` |
| `v1.2.3` | `{{minor}}` | `2` |
| `v1.2.3` | `{{patch}}` | `3` |
| `v2.0.8-beta.67` | `{{raw}}` | `2.0.8-beta.67`* |
| `v2.0.8-beta.67` | `{{raw}}` | `v2.0.8-beta.67` |
| `v2.0.8-beta.67` | `{{version}}` | `2.0.8-beta.67` |
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | `2.0.8-beta.67`* |
> *Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag because they are updated frequently,
> and contain many breaking changes that are (by the author's design) not yet fit for public consumption.
> *Pre-release (rc, beta, alpha) will only extend `{{version}}` (or `{{raw}}` if specified) as tag
> because they are updated frequently, and contain many breaking changes that are (by the author's design)
> not yet fit for public consumption.
Extended attributes and default values:
Expand Down Expand Up @@ -446,15 +447,16 @@ custom value through `value` attribute.
| `v1.2.3` | `{{version}}` | `1.2.3` |
| `1.2.3` | `{{major}}.{{minor}}` | `1.2` |
| `1.2.3` | `v{{major}}` | `v1` |
| `1.2.3rc2` | `{{raw}}` | `1.2.3rc2`* |
| `v1.2.3rc2` | `{{raw}}` | `v1.2.3rc2` |
| `1.2.3rc2` | `{{version}}` | `1.2.3rc2` |
| `1.2.3rc2` | `{{major}}.{{minor}}` | `1.2.3rc2`* |
| `1.2.3post1` | `{{major}}.{{minor}}` | `1.2.3.post1`* |
| `1.2.3beta2` | `{{major}}.{{minor}}` | `1.2.3b2`* |
| `1.0dev4` | `{{major}}.{{minor}}` | `1.0.dev4`* |
> *dev/pre/post release will only extend `{{version}}` as tag because they are updated frequently,
> and contain many breaking changes that are (by the author's design) not yet fit for public consumption.
> *dev/pre/post release will only extend `{{version}}` (or `{{raw}}` if specified) as tag
> because they are updated frequently, and contain many breaking changes that are (by the author's design)
> not yet fit for public consumption.
Extended attributes and default values:
Expand Down
23 changes: 23 additions & 0 deletions __tests__/fixtures/event_tag_v1.2.3rc2.env
@@ -0,0 +1,23 @@
GITHUB_ACTION=crazy-maxghaction-dump-context
GITHUB_ACTIONS=true
GITHUB_ACTION_PATH=/home/runner/work/_actions/crazy-max/ghaction-dump-context/v1
GITHUB_ACTOR=crazy-max
GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_EVENT_NAME=push
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=event
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_REF=refs/tags/v1.2.3rc2
GITHUB_REPOSITORY=crazy-max/test-docker-action
GITHUB_REPOSITORY_OWNER=crazy-max
GITHUB_RETENTION_DAYS=90
GITHUB_RUN_ID=325968230
GITHUB_RUN_NUMBER=4
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
GITHUB_WORKFLOW=event
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action
32 changes: 32 additions & 0 deletions __tests__/meta.test.ts
Expand Up @@ -1700,6 +1700,38 @@ describe('tag', () => {
"org.opencontainers.image.licenses=MIT"
]
],
[
'tag32',
'event_tag_v1.2.3rc2.env',
{
images: ['org/app', 'ghcr.io/user/app'],
tags: [
`type=pep440,pattern={{raw}}`,
`type=pep440,pattern={{major}}.{{minor}}`
]
} as Inputs,
{
main: 'v1.2.3rc2',
partial: ['1.2.3rc2'],
latest: false
} as Version,
[
'org/app:v1.2.3rc2',
'org/app:1.2.3rc2',
'ghcr.io/user/app:v1.2.3rc2',
'ghcr.io/user/app:1.2.3rc2'
],
[
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v1.2.3rc2",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
]
],
])('given %p with %p event', tagsLabelsTest);
});

Expand Down
7 changes: 6 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/meta.ts
Expand Up @@ -175,7 +175,11 @@ export class Meta {
let latest: boolean = false;
const pver = pep440.explain(vraw);
if (pver.is_prerelease || pver.is_postrelease || pver.is_devrelease) {
vraw = this.setValue(pep440.clean(vraw), tag);
if (Meta.isRawStatement(tag.attrs['pattern'])) {
vraw = this.setValue(vraw, tag);
} else {
vraw = this.setValue(pep440.clean(vraw), tag);
}
} else {
vraw = this.setValue(
handlebars.compile(tag.attrs['pattern'])({
Expand Down

0 comments on commit e562237

Please sign in to comment.