Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meedamian/tag-suggestions
Github Action to suggest short tags, given a new one added
https://github.com/meedamian/tag-suggestions
docker-hub docker-tags github-action semver
Last synced: about 4 hours ago
JSON representation
Github Action to suggest short tags, given a new one added
- Host: GitHub
- URL: https://github.com/meedamian/tag-suggestions
- Owner: meeDamian
- License: mit
- Created: 2019-09-12T20:39:48.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-22T19:00:04.000Z (over 4 years ago)
- Last Synced: 2024-04-14T22:32:10.874Z (7 months ago)
- Topics: docker-hub, docker-tags, github-action, semver
- Language: Shell
- Size: 28.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# meeDamian/tag-suggestions
[![main_gh_action_svg]][main_gh_action_url]
[![branches_gh_action_svg]][branches_gh_action_url]
[![gh_last_release_svg]][gh_last_release_url]
[![tippin_svg]][tippin_url][main_gh_action_svg]: https://github.com/meeDamian/tag-suggestions/workflows/Release%20branches/badge.svg
[main_gh_action_url]: https://github.com/meeDamian/tag-suggestions/blob/master/.github/workflows/main.yml[branches_gh_action_svg]: https://github.com/meeDamian/tag-suggestions/workflows/Use%20self%20to%20generate%20tags/badge.svg
[branches_gh_action_url]: https://github.com/meeDamian/tag-suggestions/blob/master/.github/workflows/on-tag.yml[gh_last_release_svg]: https://img.shields.io/github/v/release/meeDamian/tag-suggestions?sort=semver
[gh_last_release_url]: https://github.com/meeDamian/tag-suggestions/releases/latest[tippin_svg]: https://img.shields.io/badge/donate-lightning-FDD023?logo=bitcoin&style=flat
[tippin_url]: https://tippin.me/@meeDamianGithub Action to, based on git tags, generate convenience Docker tags.
#### Human language
In other words, this action suggests you what extra tags to create for Docker Hub upon new version-tag creation. For example, given existing tags: `v1.0.0`, `v1.0.1`, `v1.1.0`, and new tag being added: `v1.0.2` this action would recommend the creation of `v1.0`, but not `:latest` (as a tag with higher version exists), nor `:v1` (as a newer tag with the same major version exists).
# Usage
See [action.yml](action.yml)
### Example usage
```yaml
on:
push:
tags: [ '*' ]
…steps:
- uses: actions/checkout@v1- uses: meeDamian/[email protected]
id: tags- name: Print all recommended versions
run: |
echo "latest: ${{ steps.tags.outputs.latest }}"
echo "major: ${{ steps.tags.outputs.major }}"
echo "minor: ${{ steps.tags.outputs.minor }}"- name: Tag minor version, if recommended
run: |
# convert to lowercase
REPO="${GITHUB_REPOSITORY,,}"# extract tag from `$GITHUB_REF`. Only works if workflow triggered by tag push.
VERSION="${GITHUB_REF#refs/tags/}"if [ -n "${{ steps.tags.outputs.minor }}" ]; then
NEW_TAG="$REPO:${{ steps.tags.outputs.minor }}"docker tag "$REPO:$VERSION" "$NEW_TAG"
docker push "$NEW_TAG"
fi
```### Arguments
| name | required | description
|:----------------:|:----------:|-------------
| `tag` | sometimes | Git tag to base suggestions on. If not provided, an extraction from `${GITHUB_REF}` is attempted (AKA not needed on git tag push).### Outputs
For a `tag: vX.Y.Z`
| name | value | description
|:--------:|----------|-------------
| `latest` | `latest` | Only set if `:latest` tag creation is recommended.
| `major` | `vX` | Only set if major tag creation is recommended.
| `minor` | `vX.Y` | Only set if minor tag creation is recommended.### Versioning
As of Sep 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]"_, I'm creating permanent git tags for each release in a semver format prefixed with `v`, **as well as** maintain branches with shortened tags. You can see the exact process [here].
Ex. `1.0` branch always points to the newest `v1.0.x` tag.
In practice:
```yaml
# For exact version
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.
[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)