-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8a11935
Showing
6 changed files
with
461 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Create shortened tags | ||
|
||
# Only triggered on git tag push | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
shorten: | ||
name: Short tags | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Make sure that current tag is merged to master | ||
run: | | ||
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 | ||
- name: Create, or update the short-name branch | ||
run: | | ||
cd "${GITHUB_WORKSPACE}" | ||
git config user.name "${GITHUB_ACTOR}" | ||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
TAG=$(echo "${GITHUB_REF}" | awk -F/ '{print $NF}') | ||
SHORT=$(echo "${TAG}" | tr -d v | cut -d. -f-2) | ||
git branch -f "${SHORT}" "${TAG}" | ||
REMOTE="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" | ||
git push --force "${REMOTE}" "${SHORT}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM alpine:3.10 | ||
|
||
RUN apk update \ | ||
&& apk add file curl jq | ||
|
||
COPY entrypoint.sh / | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Damian Mee | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# github-release | ||
|
||
Github Action to create and update Github Releases, as well as upload assets to them. | ||
|
||
# Usage | ||
|
||
See [action.yml](action.yml) | ||
|
||
### Minimal | ||
|
||
```yaml | ||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- uses: meeDamian/[email protected] | ||
with: | ||
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. | ||
|
||
[arguments]: #Arguments | ||
|
||
### Arguments | ||
|
||
| 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 | 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` | 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 | ||
|
||
#### Files syntax | ||
|
||
In it's simplest form it takes a single file/folder to be compressed & uploaded: | ||
|
||
```yaml | ||
with: | ||
… | ||
files: release/ | ||
``` | ||
|
||
Each uploaded element can also be named by prefixing the path to it with: `<name>:`, example: | ||
|
||
```yaml | ||
with: | ||
… | ||
files: release-v1.0.0:release/ | ||
``` | ||
|
||
As of Aug 2019, Github Actions doesn't support list arguments to actions, so to pass multiple files, pass them as a space-separated string. To do that in an easier to read way, [YAML multiline syntax] can be used, example: | ||
|
||
```yaml | ||
with: | ||
… | ||
files: > | ||
release-v1.0.0-linux:release/linux/ | ||
release-v1.0.0-mac:release/darwin/ | ||
release-v1.0.0-windows:release/not-supported-notice | ||
checksums.txt | ||
``` | ||
[YAML multiline syntax]: https://yaml-multiline.info/ | ||
|
||
### Advanced example | ||
|
||
```yaml | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: meeDamian/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: v1.3.6 | ||
name: My Creative Name | ||
body: > | ||
This release actually changes the fabric of the reality, so be careful | ||
while applying, as error in database migration, can irrecoverably wipe | ||
some laws of physics. | ||
gzip: folders | ||
files: > | ||
Dockerfile | ||
action.yml | ||
.github/ | ||
license:LICENSE | ||
work-flows:.github/ | ||
``` | ||
|
||
|
||
### Versioning | ||
|
||
As of Aug 2019, Github Actions doesn't natively understand shortened tags in `uses:` directive. | ||
|
||
To go around that and not do what [`git-tag-manual` calls _"The insane thing"_][insane], I'm creating permanent git tags for each release in a semver format prefixed with `v`, **as well as** maintain branches with shortened tags. | ||
|
||
Ex. `1.4` branch always points to the newest `v1.4.x` tag, etc. | ||
|
||
In practice: | ||
|
||
```yaml | ||
# For exact tags | ||
steps: | ||
uses: meeDamian/[email protected] | ||
``` | ||
Or | ||
```yaml | ||
# For newest minor version 1.0 | ||
steps: | ||
uses: meeDamian/[email protected] | ||
``` | ||
|
||
Note: It's likely branches will be deprecated once Github Actions fixes its limitation. | ||
|
||
[insane]: https://git-scm.com/docs/git-tag#_on_re_tagging | ||
|
||
# License | ||
|
||
The scripts and documentation in this project are released under the [MIT License](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Github Release create, update, and upload assets | ||
description: Github Action to create, update, or add files to Github Releases | ||
author: 'Damian Mee <[email protected]>' | ||
|
||
inputs: | ||
# Exposed Github API inputs (identical to ones consumed by Github API): | ||
# https://developer.github.com/v3/repos/releases/#create-a-release | ||
# NOTE: No defaults set for these, to avoid override on update due to the impossibility | ||
# of distinguishing between default, and user input. | ||
token: | ||
description: Github API token to be used. Quite crucial, I'm afraid. | ||
required: true | ||
|
||
tag: | ||
description: > | ||
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`. | ||
required: false | ||
|
||
name: | ||
description: Place to 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. | ||
required: false | ||
|
||
draft: | ||
description: Set to true to create a release, but not publish it. | ||
required: false | ||
|
||
prerelease: | ||
description: Marks this as a pre-release. | ||
required: false | ||
|
||
# This action specific inputs: | ||
files: | ||
description: > | ||
A space-separated(!) list of files to be uploaded. It's impossible to pass a list here, so make sure filenames | ||
don't contain spaces in their names, or paths. You can optionally specify a custom asset name by pre-pending it | ||
to the name like this: `asset-name.tgz:./folder-to-be-uploaded/`. | ||
required: false | ||
|
||
gzip: | ||
description: > | ||
If set to `true` (default) compresses both files, and folders. If set to `false`, uploads files exactly as they are, but | ||
errors on folders. If set to `folders`, uploads files as-they-are, but compresses folders. | ||
required: false | ||
default: true | ||
|
||
allow_override: | ||
description: Set to `true` to allow for release overriding. | ||
required: false | ||
default: false | ||
|
||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
|
||
branding: | ||
color: 'green' | ||
icon: 'github' |
Oops, something went wrong.