Skip to content

Commit

Permalink
rename some files and add tag push support
Browse files Browse the repository at this point in the history
  • Loading branch information
smac89 committed Nov 18, 2023
1 parent 0e581bd commit 621ccc0
Show file tree
Hide file tree
Showing 10 changed files with 357 additions and 212 deletions.
79 changes: 64 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Actions Tagger

:speedboat: Keep your action versions up-to-date by automatically promoting a major tag (and optionally, a `latest` tag) each time a release is created.
:speedboat: Keep your action versions up-to-date by automatically promoting a
major tag (and optionally, a `latest` tag) each time a release is created.

# Rationale

According to the github actions [versioning guide](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#versioning), actions publishers should have a major tag (`v1`, `v2`, etc) which points to the latest version of any minor/patch release of their action, for ease of use by the others.
According to the github actions
[versioning guide](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#versioning),
actions publishers should have a major tag (`v1`, `v2`, etc) which points to the
latest version of any minor/patch release of their action, for ease of use by
the others.

I found this process quite tedious, and repetitive which is why this action exists. If you have published an action and would like to have your action follow the same versioning structure as many others in the [marketplace](https://github.com/marketplace?type=actions), then simply create a release workflow that includes this action. See the [_usage_ example](#sample-usage).
I found this process quite tedious, and repetitive which is why this action
exists. If you have published an action and would like to have your action
follow the same versioning structure as many others in the
[marketplace](https://github.com/marketplace?type=actions), then simply create a
release workflow that includes this action. See the
[_usage_ example](#sample-usage).

---

Expand All @@ -16,15 +26,17 @@ I found this process quite tedious, and repetitive which is why this action exis

### `publish_latest_tag`

Indicates to the action whether or not to create/update a tag called `latest` pointing to the latest release. **Default: `"false"`**.
Indicates to the action whether or not to create/update a tag called `latest`
pointing to the latest release. **Default: `"false"`**.

### `prefer_branch_releases`

Do you prefer creating `vN` branches or `vN` tags? **Default: `"false"`**

### `token`

A github token used for creating an octoclient for making API calls. **Default: `${{ github.token }}`**.
A github token used for creating an octoclient for making API calls. **Default:
`${{ github.token }}`**.

## Outputs

Expand All @@ -37,19 +49,23 @@ The version of the branch/tag that was published/updated.
Was _latest_ also published?

### <strike>`ref_name`</strike>

**Deprecated in v3:** _Use [`tag`](#tag)_

# Env Inputs

### `GITHUB_TOKEN`

**Deprecated in v3:** _If a non-default PAT (Personal Access Token) is needed, use [`token`](#token) instead._
**Deprecated in v3:** _If a non-default PAT (Personal Access Token) is needed,
use [`token`](#token) instead._

# Debug Logging

This action supports [debug logging](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging#enabling-step-debug-logging). When enabled, it will dump the output of the
api call for creating the tags/branches.
This is useful for testing and should be included when reporting bugs.
This action supports
[debug logging](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging#enabling-step-debug-logging).
When enabled, it will dump the output of the api call for creating the
tags/branches. This is useful for testing and should be included when reporting
bugs.

# Sample Usage

Expand All @@ -60,30 +76,63 @@ name: Keep the versions up-to-date

on:
release:
types: [published, edited]
types:
- published
- edited
push: #(1)
tags-ignore:
- 'v[0-9]+'
- 'latest'
branches-ignore:
- '**'
paths-ignore:
- '**'

jobs:
actions-tagger:
runs-on: windows-latest
permissions: # (1)
permissions: # (2)
contents: write
steps:
- uses: Actions-R-Us/actions-tagger@latest
with:
publish_latest_tag: true
```
_Note this action is able to detect if it is being run in a **release** context, and if not it will notify you and exit gracefully._
---
### Notes
1. The [`permissions`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions) option is only required if the workflow permission for the given repository is set to readonly. `readonly` permission renders the main purpose of this action useless because it will be unable to create tags. Using the `contents: write` scope allows this action to once again gain the ability to create/update tags. For more details on changing the workflow permissions for a given repository, see [Configuring the default `GITHUB_TOKEN` permissions](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#configuring-the-default-github_token-permissions). For more details on the various available scopes that can be configured for the `GITHUB_TOKEN`, see [`permissions`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions).
It is also important to note that when modifying one scope of the [permission of `GITHUB_TOKEN`](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token), all other unspecified scopes are set to _no access_ with the exception of the `metadata` scope, which is set to `read`. See [Modifying the permissions for the `GITHUB_TOKEN`](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token) for more details. This shouldn't be a concern for this action, because it only exclusively deals with the contents of the given repository.
1. Add the push configuration if you want this action to also run when a new tag or branch is created.
**An event will [not be created](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push) when more than three tags are pushed at once.**
If you want to track branches, swap the filters listed under `branches-ignore`
and `tags-ignore`. At all times, leave the filter for `paths-ignore` as is.
2. The
[`permissions`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions)
option is only required if the workflow permission for the given repository
is set to readonly. `readonly` permission renders the main purpose of this
action useless because it will be unable to create tags. Using the
`contents: write` scope allows this action to once again gain the ability to
create/update tags. For more details on changing the workflow permissions for
a given repository, see
[Configuring the default `GITHUB_TOKEN` permissions](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#configuring-the-default-github_token-permissions).
For more details on the various available scopes that can be configured for
the `GITHUB_TOKEN`, see
[`permissions`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions).

It is also important to note that when modifying one scope of the
[permission of `GITHUB_TOKEN`](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token),
all other unspecified scopes are set to _no access_ with the exception of the
`metadata` scope, which is set to `read`. See
[Modifying the permissions for the `GITHUB_TOKEN`](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token)
for more details. This shouldn't be a concern for this action, because it
only exclusively deals with the contents of the given repository.

---

# Similar projects

### [EndBug/latest-tag](https://github.com/EndBug/latest-tag)

- Creates a `latest` tag
Loading

0 comments on commit 621ccc0

Please sign in to comment.