-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (49 loc) · 1.92 KB
/
release-published.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
on:
release:
types: [published]
workflow_dispatch:
inputs:
release-version:
description: 'Release version'
type: string
required: true
name: '[autorelease] Release published'
jobs:
update-ref:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get release version
id: get-release-version
run: |
VERSION="${{ github.event.release.tag_name }}"
if [[ ! $VERSION ]]; then
VERSION="${{ github.event.inputs.release-version }}"
fi
RE='^[vV]?([0-9]+)[.]([0-9]+)[.]([0-9]+)(-[0-9A-Za-z.+-]*)?'
if [[ $VERSION =~ $RE ]]; then
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
PATCH="${BASH_REMATCH[3]}"
PRERELEASE="${BASH_REMATCH[4]}"
else
echo "::error::Version '$VERSION' is not in a valid format" && exit 1
fi
echo "::set-output name=semver-tag::$VERSION"
echo "::set-output name=major-ref::v$MAJOR"
if [[ "$PRERELEASE" ]]; then pre=true; else pre=false; fi
echo "::set-output name=is-prerelease::$pre"
- name: Prerelease
if: fromJSON(steps.get-release-version.outputs.is-prerelease)
run: |
echo "::notice::Pre-release version detected, not moving ref ${{ steps.get-release-version.outputs.major-ref }}"
- name: Update release tag
if: ${{ ! fromJSON(steps.get-release-version.outputs.is-prerelease) }}
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -fa ${{ steps.get-release-version.outputs.major-ref }} -m "Update ${{ steps.get-release-version.outputs.major-ref }} tag"
git push origin ${{ steps.get-release-version.outputs.major-ref }} --force
echo "::notice::Updated ref ${{ steps.get-release-version.outputs.major-ref }}"