-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (56 loc) · 2.54 KB
/
on-release-tag.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Build on Tag
run-name: "${{ github.workflow }}: [on ${{ github.event_name != 'workflow_dispatch' && github.ref_type || 'workflow_dispatch' }}] [ref: ${{ github.ref_name }}]"
# Only on release tags.
on:
push:
# Release tags only
tags:
# - v[0-9]+.[0-9]+.[0-9]+-*
- v[0-9]+.[0-9]+.[0-9]+
# Allows you to run this workflow manually from the Actions tab (for testing)
workflow_dispatch:
permissions:
contents: read
jobs:
setup:
name: "Validate version"
runs-on: ubuntu-latest
outputs:
status: ${{ steps.validated.conclusion }}
buildRef: ${{ steps.validated.outputs.BUILD_REF_TAG }}
packageVersion: ${{ steps.validated.outputs.PACKAGE_VERSION }}
steps:
- name: "Checkout local @master repository"
uses: actions/checkout@v3
# checkouts $GITHUB_REF_NAME
# Version in package.json has to be the same as the ref TAG that fired this workflow.
- name: Validate TAG and PACKAGE versions
id: validated
run: |
echo "Github event: ${{ github.event_name }}"
echo "Using ${GITHUB_REPOSITORY#*/} @$GITHUB_REF_NAME for build"
PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
# GITHUB_REF_NAME will always be a semantic version tag in this workflow, if not, error.
BUILD_REF_TAG=${{ github.ref_name }}
echo "PACKAGE_VERSION=$PACKAGE_VERSION"
echo "BUILD_REF_TAG=$BUILD_REF_TAG"
# skip exit if this is a test tag or workflow_dispatch.
if [[ "$BUILD_REF_TAG" != "v$PACKAGE_VERSION" ]]; then
if [[ ("$BUILD_REF_TAG" == "v0.0.0") || ("$GITHUB_EVENT_NAME" == "workflow_dispatch") ]]; then
echo "::warning title="Version mismatch skiped"::Package: 'v$PACKAGE_VERSION' and tag: '$BUILD_REF_TAG' version mismatch"
else
echo "::error title="Version mismatch"::Package: 'v$PACKAGE_VERSION' and tag: '$BUILD_REF_TAG' version mismatch!"
exit 1
fi
fi
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
echo "BUILD_REF_TAG=$BUILD_REF_TAG" >> $GITHUB_OUTPUT
shell: bash
# Build vscode extension with formatter_server native daemons
build_extension:
needs: [setup]
if: needs.setup.outputs.status == 'success'
# If you use the second syntax option (without {owner}/{repo} and @{ref}) the called workflow is from the same commit as the caller workflow.
name: "Build Extension"
uses: ./.github/workflows/build.yml
secrets: inherit