Skip to content

Commit

Permalink
Merge pull request #12 from meeDamian/release-v2
Browse files Browse the repository at this point in the history
Version 2
  • Loading branch information
meeDamian authored Mar 15, 2020
2 parents 918936f + fb49d82 commit 95a3c77
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 144 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Create shortened tags
# Only triggered on git tag push
on:
push:
tags:
- '*'
tags: [ '*' ]

jobs:
shorten:
Expand All @@ -15,29 +14,29 @@ jobs:

- name: Make sure that current tag is merged to master
run: |
cd "${GITHUB_WORKSPACE}"
cd "$GITHUB_WORKSPACE"
git switch master
# Returns 1 if it's not, and therefore terminates the workflow
git merge-base --is-ancestor "${GITHUB_SHA}" HEAD
git merge-base --is-ancestor "$GITHUB_SHA" HEAD
- name: Create, or update the short-name branch
run: |
cd "${GITHUB_WORKSPACE}"
cd "$GITHUB_WORKSPACE"
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
TAG=$(echo "${GITHUB_REF}" | awk -F/ '{print $NF}')
SHORT=$(echo "${TAG}" | tr -d v | cut -d. -f-2)
TAG=$(echo "$GITHUB_REF" | awk -F/ '{print $NF}')
SHORT=$(echo "${TAG#v}" | cut -d. -f-2)
# Do nothing on test tags
if [[ "${SHORT}" = "0.0" ]]; then
if [[ "$SHORT" = "0.0" ]]; then
exit 0
fi
git branch -f "${SHORT}" "${TAG}"
git branch -f "$SHORT" "$TAG"
REMOTE="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
git push --force "${REMOTE}" "${SHORT}"
REMOTE="https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git"
git push --force "$REMOTE" "$SHORT"
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM alpine:3.10
FROM alpine:3.11

RUN apk update \
&& apk add file curl jq
RUN apk add --no-cache file curl jq

COPY entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT [ "/entrypoint.sh" ]
67 changes: 40 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,29 @@

Github Action to create and update Github Releases, as well as upload assets to them.

> ### **NOTICE:** This action is now deprecated, and official actions should be used instead:

> ### **NOTICE_2:** Deprecation <small>temporarily</small> cancelled, because GH actions are just awful.
>
> ### ~~**NOTICE:** This action is now deprecated, and official actions should be used instead:~~
>
> * https://github.com/actions/create-release
> * https://github.com/actions/upload-release-asset
> * ~~https://github.com/actions/create-release~~
> * ~~https://github.com/actions/upload-release-asset~~

# Usage

See [action.yml](action.yml)


### Minimal

```yaml
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- uses: meeDamian/github-release@1.0
- uses: meeDamian/github-release@2.0
with:
token: ${{secrets.GITHUB_TOKEN}}
token: ${{ secrets.GITHUB_TOKEN }}
```
`token` is the only **always required** parameter to be passed to this action. Everything else can use sane defaults in some circumstances. See [arguments] to learn more.
Expand All @@ -44,22 +49,23 @@ steps:

All inputs are available as a _normal_ Action input, but because Github Actions don't accept shell variables there, some are also available as an Environment Variable set beforehand. When both set, one set as input takes precedence.

| name | ENV var alternative | required | description
|:----------------:|:-------------------:|:----------:|----------------
| `token` | - | **always** | Github Access token. Can be accessed by using `${{secrets.GITHUB_TOKEN}}` in the workflow file.
| `tag` | `RELEASE_TAG` | sometimes | If triggered by git tag push, tag is picked up automatically. Otherwise `tag:` has to be set. For tags constructed dynamically, use `RELEASE_TAG` env var.
| `commitish` | - | no | Commit hash this release should point to. Unnecessary, if `tag` is a git tag. Otherwise, current `master` is used. [more]
| `name` | `RELEASE_NAME` | no | Place to name the release, the more creative, the better. Defaults to the name of the tag used. [more]
| `body` | - | no | Place to put a longer description of the release, ex changelog, or info about contributors. Defaults to the commit message of the reference commit. [more]
| `draft` | - | no | Set to `true` to create a release, but not publish it. `false` by default. [more]
| `prerelease` | - | no | Marks this release as a pre-release. `false` by default. [more]
| `files` | `RELEASE_FILES` | no | A **space-separated** list of files to be uploaded. When left empty, no files are uploaded. [More on files below]
| `gzip` | - | no | Set whether to `gzip` uploaded assets, or not. Available options are: `true`, `false`, and `folders` which uploads files unchanged, but compresses directories/folders. Defaults to `true`. Note: it errors if set to `false`, and `files:` argument contains path to a directory.
| `allow_override` | - | no | Allow override of release, if one with the same tag already exists. Defaults to `false`
| name | required | description
|:----------------:|:----------:|----------------
| `token` | **always** | Github Access token. Can be accessed by using `${{ secrets.GITHUB_TOKEN }}` in the workflow file.
| `tag` | sometimes | If triggered by git tag push, tag is picked up automatically. Otherwise `tag:` has to be set.
| `commitish` | no | Commit hash this release should point to. Unnecessary, if `tag` is a git tag. Otherwise, current `master` is used. [more]
| `name` | no | Name the release, the more creative, the better. Defaults to the name of the tag used. [more]
| `body` | no | Longer description of the release, ex changelog, or info about contributors. Defaults to the commit message of the reference commit. [more]
| `draft` | no | Set to `true` to create a release, but not publish it. `false` by default. [more]
| `prerelease` | no | Mark this release as a pre-release. `false` by default. [more]
| `files` | no | A **space-separated** list of files to be uploaded. When left empty, no files are uploaded. [More on files below]
| `gzip` | no | Set whether to `gzip` uploaded assets, or not. Available options are: `true`, `false`, and `folders` which uploads files unchanged, but compresses directories/folders. Defaults to `true`. Note: it errors if set to `false`, and `files:` argument contains path to a directory.
| `allow_override` | no | Allow override of release, if one with the same tag already exists. Defaults to `false`

[more]: https://developer.github.com/v3/repos/releases/#create-a-release
[More on files below]: #Files-syntax


#### Using ENV vars

In a step before this action, run ex:
Expand All @@ -70,21 +76,24 @@ steps:
- name: Set enviroment for github-release
run: |
echo ::set-env name=RELEASE_TAG::"v1.0.0"
echo ::set-env name=RELEASE_NAME::"${GITHUB_WORKFLOW}"
echo ::set-env name=RELEASE_NAME::"$GITHUB_WORKFLOW"
- uses: meeDamian/github-release@1.0
- uses: meeDamian/github-release@2.0
with:
token: ${{secrets.GITHUB_TOKEN}}
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.RELEASE_TAG }}
name: ${{ env.RELEASE_NAME }}
...
```

To learn more about notation used above see [this].

[this]: https://help.github.com/en/articles/development-tools-for-github-actions#set-an-environment-variable-set-env


#### Files syntax

In it's simplest form it takes a single file/folder to be compressed & uploaded:
In its simplest form it takes a single file/folder to be compressed & uploaded:

```yaml
with:
Expand Down Expand Up @@ -113,16 +122,17 @@ with:
```
[YAML multiline syntax]: https://yaml-multiline.info/


### Advanced example

```yaml
steps:
- uses: actions/checkout@master
- uses: meeDamian/github-release@0.1
- uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: v1.3.6
tag: ${{ env.MY_CUSTOM_TAG }}
name: My Creative Name
body: >
This release actually changes the fabric of the reality, so be careful
Expand Down Expand Up @@ -151,20 +161,23 @@ In practice:
```yaml
# For exact version
steps:
uses: meeDamian/github-release@v1.0.1
uses: meeDamian/github-release@v2.0.0
```

Or

```yaml
# For newest minor version 1.0
# For newest minor version 2.0
steps:
uses: meeDamian/github-release@1.0
uses: meeDamian/github-release@2.0
```

Note: It's likely branches will be deprecated once Github Actions fixes its limitation.

[The insane thing]: https://git-scm.com/docs/git-tag#_on_re_tagging
[here]: .github/workflows/on-tag.yml


# License

The scripts and documentation in this project are released under the [MIT License](LICENSE)
15 changes: 9 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,33 @@ inputs:

tag:
description: >
A tag for the release. Required UNLESS action is run on tag push (meaning: `${GITHUB_REF}` contains `ref/tag/<TAG>`).
A tag for the release. Required UNLESS action is run on tag push (meaning: `$GITHUB_REF` contains `ref/tag/<TAG>`).
required: false

commitish:
description: Unnecessary, if the tag provided is a git tag. If it isn't release will be made off `master`.
description: Unnecessary, if the tag provided is a git tag. If it isn't, release will be made off `master`.
required: false

name:
description: Place to name the release, the more creative, the better.
description: Name the release, the more creative, the better.
required: false

body:
description: Place to put a longer description of the release, ex changelog, or info about contributors.
description: Longer description of the release, ex changelog, or info about contributors.
required: false

draft:
description: Set to true to create a release, but not publish it.
description: >
Whether to keep the Release as draft, and not publish it. Defaults to 'false', unless files are specified, when
a draft Release is created first, and published only if all asset uploads succeed. Prevent by explicitly setting
it to 'false'.
required: false

prerelease:
description: Marks this as a pre-release.
required: false

# This action specific inputs:
# Inputs specific to this-action:
files:
description: >
A space-separated(!) list of files to be uploaded. It's impossible to pass a list here, so make sure filenames
Expand Down
Loading

0 comments on commit 95a3c77

Please sign in to comment.