Skip to content

Commit e562237

Browse files
authored
Merge pull request #156 from crazy-max/prerelease-raw-pep440
fix: handle raw statement for pep440 pre-release
2 parents 6d7c94a + aad230b commit e562237

File tree

5 files changed

+74
-8
lines changed

5 files changed

+74
-8
lines changed

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,13 @@ attribute.
404404
| `v1.2.3` | `v{{major}}` | `v1` |
405405
| `v1.2.3` | `{{minor}}` | `2` |
406406
| `v1.2.3` | `{{patch}}` | `3` |
407-
| `v2.0.8-beta.67` | `{{raw}}` | `2.0.8-beta.67`* |
407+
| `v2.0.8-beta.67` | `{{raw}}` | `v2.0.8-beta.67` |
408408
| `v2.0.8-beta.67` | `{{version}}` | `2.0.8-beta.67` |
409409
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | `2.0.8-beta.67`* |
410410

411-
> *Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag because they are updated frequently,
412-
> and contain many breaking changes that are (by the author's design) not yet fit for public consumption.
411+
> *Pre-release (rc, beta, alpha) will only extend `{{version}}` (or `{{raw}}` if specified) as tag
412+
> because they are updated frequently, and contain many breaking changes that are (by the author's design)
413+
> not yet fit for public consumption.
413414

414415
Extended attributes and default values:
415416

@@ -446,15 +447,16 @@ custom value through `value` attribute.
446447
| `v1.2.3` | `{{version}}` | `1.2.3` |
447448
| `1.2.3` | `{{major}}.{{minor}}` | `1.2` |
448449
| `1.2.3` | `v{{major}}` | `v1` |
449-
| `1.2.3rc2` | `{{raw}}` | `1.2.3rc2`* |
450+
| `v1.2.3rc2` | `{{raw}}` | `v1.2.3rc2` |
450451
| `1.2.3rc2` | `{{version}}` | `1.2.3rc2` |
451452
| `1.2.3rc2` | `{{major}}.{{minor}}` | `1.2.3rc2`* |
452453
| `1.2.3post1` | `{{major}}.{{minor}}` | `1.2.3.post1`* |
453454
| `1.2.3beta2` | `{{major}}.{{minor}}` | `1.2.3b2`* |
454455
| `1.0dev4` | `{{major}}.{{minor}}` | `1.0.dev4`* |
455456

456-
> *dev/pre/post release will only extend `{{version}}` as tag because they are updated frequently,
457-
> and contain many breaking changes that are (by the author's design) not yet fit for public consumption.
457+
> *dev/pre/post release will only extend `{{version}}` (or `{{raw}}` if specified) as tag
458+
> because they are updated frequently, and contain many breaking changes that are (by the author's design)
459+
> not yet fit for public consumption.
458460

459461
Extended attributes and default values:
460462

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
GITHUB_ACTION=crazy-maxghaction-dump-context
2+
GITHUB_ACTIONS=true
3+
GITHUB_ACTION_PATH=/home/runner/work/_actions/crazy-max/ghaction-dump-context/v1
4+
GITHUB_ACTOR=crazy-max
5+
GITHUB_API_URL=https://api.github.com
6+
GITHUB_BASE_REF=
7+
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_6ee180c2-b331-434a-a867-89534cbefd83
8+
GITHUB_EVENT_NAME=push
9+
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
10+
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
11+
GITHUB_HEAD_REF=
12+
GITHUB_JOB=event
13+
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_6ee180c2-b331-434a-a867-89534cbefd83
14+
GITHUB_REF=refs/tags/v1.2.3rc2
15+
GITHUB_REPOSITORY=crazy-max/test-docker-action
16+
GITHUB_REPOSITORY_OWNER=crazy-max
17+
GITHUB_RETENTION_DAYS=90
18+
GITHUB_RUN_ID=325968230
19+
GITHUB_RUN_NUMBER=4
20+
GITHUB_SERVER_URL=https://github.com
21+
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
22+
GITHUB_WORKFLOW=event
23+
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action

__tests__/meta.test.ts

+32
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,38 @@ describe('tag', () => {
17001700
"org.opencontainers.image.licenses=MIT"
17011701
]
17021702
],
1703+
[
1704+
'tag32',
1705+
'event_tag_v1.2.3rc2.env',
1706+
{
1707+
images: ['org/app', 'ghcr.io/user/app'],
1708+
tags: [
1709+
`type=pep440,pattern={{raw}}`,
1710+
`type=pep440,pattern={{major}}.{{minor}}`
1711+
]
1712+
} as Inputs,
1713+
{
1714+
main: 'v1.2.3rc2',
1715+
partial: ['1.2.3rc2'],
1716+
latest: false
1717+
} as Version,
1718+
[
1719+
'org/app:v1.2.3rc2',
1720+
'org/app:1.2.3rc2',
1721+
'ghcr.io/user/app:v1.2.3rc2',
1722+
'ghcr.io/user/app:1.2.3rc2'
1723+
],
1724+
[
1725+
"org.opencontainers.image.title=Hello-World",
1726+
"org.opencontainers.image.description=This your first repo!",
1727+
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
1728+
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
1729+
"org.opencontainers.image.version=v1.2.3rc2",
1730+
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
1731+
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
1732+
"org.opencontainers.image.licenses=MIT"
1733+
]
1734+
],
17031735
])('given %p with %p event', tagsLabelsTest);
17041736
});
17051737

dist/index.js

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/meta.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ export class Meta {
175175
let latest: boolean = false;
176176
const pver = pep440.explain(vraw);
177177
if (pver.is_prerelease || pver.is_postrelease || pver.is_devrelease) {
178-
vraw = this.setValue(pep440.clean(vraw), tag);
178+
if (Meta.isRawStatement(tag.attrs['pattern'])) {
179+
vraw = this.setValue(vraw, tag);
180+
} else {
181+
vraw = this.setValue(pep440.clean(vraw), tag);
182+
}
179183
} else {
180184
vraw = this.setValue(
181185
handlebars.compile(tag.attrs['pattern'])({

0 commit comments

Comments
 (0)