generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (105 loc) · 3.7 KB
/
create_release_branch.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Create Release branch
on:
workflow_dispatch:
inputs:
version-bump:
required: false
type: choice
options:
- major
- minor
- patch
default: patch
description: 'Major, Minor, or Patch version bump'
jobs:
create_branch:
name: 'Create Release Branch'
runs-on: ubuntu-20.04
permissions:
contents: write
actions: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
name: Checkout
with:
ref: main
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
- name: Install semver
run: npm install -g semver
- name: Get Latest Release Version
id: get-version
run: |
RELEASE_BRANCH=$(git branch -r | grep -Eo 'releases/[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1)
echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_ENV
- name: Set Branch Name
id: set_branch
run: |
if [ -z "${RELEASE_BRANCH}" ]; then
NEW_BRANCH_NAME="releases/0.0.1"
else
OLD_VERSION=$(echo "${RELEASE_BRANCH}" | sed 's/releases\///')
NEW_VERSION=$(semver --increment ${{ inputs.version-bump }} "${OLD_VERSION}")
echo "Bumping $OLD_VERSION to $NEW_VERSION"
NEW_BRANCH_NAME="releases/${NEW_VERSION}"
fi
echo "NEW_BRANCH_NAME=${NEW_BRANCH_NAME}" >> $GITHUB_ENV
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
echo "OLD_VERSION=${OLD_VERSION}" >> $GITHUB_ENV
- name: Create Branch
run: |
git checkout -b $NEW_BRANCH_NAME
- name: Push Branch
run: |
git push origin $NEW_BRANCH_NAME
- name: Create Repository Release
run: |
gh release create v${{ env.NEW_VERSION }} \
--title v${{ env.NEW_VERSION }} \
--target ${{ env.NEW_BRANCH_NAME }} \
--generate-notes \
--notes-start-tag v${{ env.OLD_VERSION }} \
--prerelease
- name: Create Release Variables
run: |
gh variable set CURRENT_UAT_VERSION \
--body "${{ env.NEW_VERSION }}"
gh variable set CURRENT_PROD_VERSION \
--body "${{ env.OLD_VERSION }}"
env:
GH_TOKEN: ${{ secrets.GH_PAT_VARIABLES }}
- name: Trigger Functions Infra UAT Release
run: |
gh workflow run release_functions_infra.yml \
--ref $NEW_BRANCH_NAME
- name: Trigger Mongo Infra UAT Release
run: |
gh workflow run release_mongo_infra.yml \
--ref $NEW_BRANCH_NAME
- name: Trigger PNPG Functions Infra UAT Release
run: |
gh workflow run release_functions_pnpg_infra.yml \
--ref $NEW_BRANCH_NAME
- name: Trigger PNPG Mongo Infra UAT Release
run: |
gh workflow run release_mongo_pnpg_infra.yml \
--ref $NEW_BRANCH_NAME
- name: Trigger Functions UAT Release
run: |
gh workflow run release_functions.yml \
--ref $NEW_BRANCH_NAME
- name: Trigger Onboarding ms UAT Release
run: |
gh workflow run release_ms.yml \
--ref $NEW_BRANCH_NAME
- name: Trigger PNPG Functions UAT Release
run: |
gh workflow run release_pnpg_functions.yml \
--ref $NEW_BRANCH_NAME
- name: Trigger PNPG Onboarding ms UAT Release
run: |
gh workflow run release_pnpg_ms.yml \
--ref $NEW_BRANCH_NAME