Skip to content

Commit ed17bd4

Browse files
committed
🚀 Added prereleases
More stabilization
1 parent 510be4f commit ed17bd4

File tree

4 files changed

+71
-11
lines changed

4 files changed

+71
-11
lines changed

‎README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2424
with:
2525
title: MyReleaseMessage
26-
tag: MyTag
2726
```
2827
2928
## Mandatory Arguments
@@ -34,10 +33,31 @@ jobs:
3433
## Optional Arguments
3534

3635
### workdir
37-
`workdir` can be used to specify a directory that contains the repository to be published.
36+
`workdir` can be used to specify a directory that contains the repository to be published.
37+
38+
```yaml
39+
with:
40+
title: MyReleaseMessage
41+
workdir: myDirectoryName
42+
```
3843

3944
### tag
40-
`tag` can be used to set the tag of the release
45+
`tag` can be used to set the tag of the release.
46+
47+
```yaml
48+
with:
49+
title: MyReleaseMessage
50+
tag: MyTag
51+
```
52+
53+
### prerelease
54+
`prerelease` is used to publish a prerelease.
55+
56+
```yaml
57+
with:
58+
title: MyReleaseMessage
59+
prerelease: true
60+
```
4161

4262
## Notes
4363

@@ -55,7 +75,7 @@ permissions:
5575

5676
to the concrete job creating the release. For more details see the [documentation on token permissions.](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token)
5777

58-
### Use with GitHub Enterprise
78+
### GitHub Enterprise
5979

6080
To publish your release to self-hosted GitHub Enterprise, include `GH_ENTERPRISE_TOKEN` and `GH_HOST` as environment variables.
6181
For example:

‎action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ inputs:
1515
tag:
1616
description: "The tag of the release to publish"
1717
required: false
18+
prerelease:
19+
description: "Publishes a prerelease"
20+
required: false
1821

1922
runs:
2023
using: 'composite'
@@ -25,3 +28,4 @@ runs:
2528
INPUT_TITLE: ${{ inputs.title }}
2629
INPUT_WORKDIR: ${{ inputs.workdir }}
2730
INPUT_TAG: ${{ inputs.tag }}
31+
INPUT_PRERELEASE: ${{ inputs.prerelease }}

‎entrypoint.sh

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
#!/usr/bin/env sh
22

3-
if [ ! -z "${INPUT_WORKDIR}" ]; then
4-
cd "${INPUT_WORKDIR}"
5-
fi
3+
main() {
4+
if uses "${INPUT_WORKDIR}"; then
5+
cd "${INPUT_WORKDIR}"
6+
fi
67

7-
if [ -z "${INPUT_TAG}" ]; then
8-
INPUT_TAG="release-$(date +%Y%m%d%H%M%S)"
9-
fi
8+
if ! uses "${INPUT_TAG}"; then
9+
INPUT_TAG="release-$(date +%Y%m%d%H%M%S)"
10+
fi
1011

11-
gh release create $INPUT_TAG -t "${INPUT_TITLE}" --generate-notes
12+
OPTIONS=""
13+
if usesBoolean "${INPUT_PRERELEASE}"; then
14+
OPTIONS="${OPTIONS} --prerelease"
15+
fi
16+
17+
gh release create $INPUT_TAG -t "${INPUT_TITLE}" --generate-notes"${OPTIONS}"
18+
}
19+
20+
uses() {
21+
[ ! -z "${1}" ]
22+
}
23+
24+
usesBoolean() {
25+
[ ! -z "${1}" ] && [ "${1}" = "true" ]
26+
}
27+
28+
main

‎test.bats

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ setup(){
1616
teardown() {
1717
unset INPUT_WORKDIR
1818
unset INPUT_TAG
19+
unset INPUT_PRERELEASE
1920
}
2021

2122
@test "it creates a release" {
@@ -41,6 +42,24 @@ teardown() {
4142
expectMockCalledIs "/usr/local/mock/gh release create ${INPUT_TAG} -t TITLE --generate-notes"
4243
}
4344

45+
@test "it creates a prerelease" {
46+
export INPUT_TAG="TAG"
47+
export INPUT_PRERELEASE="true"
48+
49+
run /entrypoint.sh
50+
51+
expectMockCalledIs "/usr/local/mock/gh release create ${INPUT_TAG} -t TITLE --generate-notes --prerelease"
52+
}
53+
54+
@test "it doesn't create a prerelease on false" {
55+
export INPUT_TAG="TAG"
56+
export INPUT_PRERELEASE="false"
57+
58+
run /entrypoint.sh
59+
60+
expectMockCalledIs "/usr/local/mock/gh release create ${INPUT_TAG} -t TITLE --generate-notes"
61+
}
62+
4463
expectMockCalledIs() {
4564
local expected=$(echo "${1}" | tr -d '\n')
4665
local got=$(cat mockArgs | tr -d '\n')

0 commit comments

Comments
 (0)