README: document latest tag (#122) #9
Workflow file for this run
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
name: "Alias tag as latest" | |
on: | |
push: | |
tags: | |
- "v?[0-9]+.[0-9]+.[0-9]+*" | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "The existing tag to alias as latest" | |
type: "string" | |
required: true | |
jobs: | |
update-latest-tag: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: "write" | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Get the latest version tag | |
id: get-latest-tag | |
run: | | |
latest_tag=$(git tag -l | grep -E "v[0-9]+\.[0-9]+\.[0-9]+" | sort | head -n 1) | |
echo "Latest tag: $latest_tag" | |
echo "latest_tag=$latest_tag" >> $GITHUB_ENV | |
- name: Push the 'latest' tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if git rev-parse -q --verify refs/tags/latest; then | |
git tag -d latest | |
fi | |
git tag latest "$latest_tag" | |
git push --force origin latest | |