-
Notifications
You must be signed in to change notification settings - Fork 15
39 lines (34 loc) · 952 Bytes
/
tag-latest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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