-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (163 loc) · 6.01 KB
/
publish-release.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Inspired by Elementor Releasing Pipeline https://github.com/elementor/elementor
name: Create New Version
# Environmental Variables: WEB_CICD_PAT (PAT), WEB_CICD_USERNAME (GitHub Bot Username), WEB_CICD_MAIL (GitHub Bot E-mail)
on:
workflow_dispatch:
inputs:
version:
description: "Release Type"
required: true
type: choice
options:
- prerelease
- prepatch
- preminor
- premajor
- patch
- minor
- major
deploy:
description: "Deploy Directly to Our Website"
required: true
type: boolean
default: false
jobs:
bump-and-publish:
name: Bump Version and Publish
runs-on: ubuntu-latest
steps:
- name: Checkout Main Branch
uses: actions/checkout@v4
with:
token: ${{ secrets.WEB_CICD_PAT }}
ref: main
- name: Setup PHP 8.0
uses: shivammathur/setup-php@v2
with:
php-version: "8.0"
- name: Setup Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"
- name: Setup YQ
uses: chrisdickinson/setup-yq@latest
with:
yq-version: 'v4.25.2'
- name: Get Old Version
id: get_old_version
run: |
npm config set git-tag-version false
PREV_PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "PREV_PACKAGE_VERSION=${PREV_PACKAGE_VERSION}" >> $GITHUB_ENV
- name: Bump Major Version
if: "${{ github.event.inputs.version == 'major' }}"
run: npm version major
- name: Bump Minor Version
if: "${{ github.event.inputs.version == 'minor' }}"
run: npm version minor
- name: Bump Patch Version
if: "${{ github.event.inputs.version == 'patch' }}"
run: npm version patch
- name: Bump Premajor Version
if: "${{ github.event.inputs.version == 'premajor' }}"
run: |
npm version premajor --preid=beta
npm version prerelease --preid=beta
- name: Bump Preminor Version
if: "${{ github.event.inputs.version == 'preminor' }}"
run: |
npm version preminor --preid=beta
npm version prerelease --preid=beta
- name: Bump Prepatch Version
if: "${{ github.event.inputs.version == 'prepatch' }}"
run: |
npm version prepatch --preid=beta
npm version prerelease --preid=beta
- name: Bump Prerelease Version
if: "${{ github.event.inputs.version == 'prerelease' }}"
run: npm version prerelease --preid=beta
- name: Set New Version
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
- name: Push New Version with Build Files
env:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
WEB_CICD_MAIL: ${{ secrets.WEB_CICD_MAIL }}
WEB_CICD_USERNAME: ${{ secrets.WEB_CICD_USERNAME }}
run: |
bash "${GITHUB_WORKSPACE}/.github/scripts/update-version-files.sh"
bash "${GITHUB_WORKSPACE}/.github/scripts/build-files.sh"
bash "${GITHUB_WORKSPACE}/.github/scripts/commit-push-bump.sh"
- name: Get Current Version
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
- name: Create Tag
env:
WEB_CICD_MAIL: ${{ secrets.WEB_CICD_MAIL }}
WEB_CICD_USERNAME: ${{ secrets.WEB_CICD_USERNAME }}
run: |
bash "${GITHUB_WORKSPACE}/.github/scripts/create-git-tag.sh"
- name: Create ZIP File
env:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
run: |
bash "${GITHUB_WORKSPACE}/.github/scripts/build-zip.sh"
- name: Upload ZIP File to GitHub Actions Artifact
uses: actions/upload-artifact@v4
with:
name: urlslab-${{ env.PACKAGE_VERSION }}
path: ${{ github.workspace }}/**/*
- name: Create GitHub Prerelease
if: "${{ github.event.inputs.version != 'major' && github.event.inputs.version != 'minor' && github.event.inputs.version != 'patch' }}"
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.PACKAGE_VERSION }}
files: urlslab_*.zip
prerelease: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.WEB_CICD_PAT }}
- name: Create GitHub Release
if: "${{ github.event.inputs.version != 'premajor' && github.event.inputs.version != 'preminor' && github.event.inputs.version != 'prepatch' && github.event.inputs.version != 'prerelease' }}"
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.PACKAGE_VERSION }}
files: urlslab_*.zip
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.WEB_CICD_PAT }}
deploy:
name: Deploy
needs: bump-and-publish
runs-on: ubuntu-latest
if: "${{ github.event.inputs.deploy == 'true' }}"
steps:
- name: Checkout Main Branch
uses: actions/checkout@v4
with:
token: ${{ secrets.WEB_CICD_PAT }}
ref: main
- name: Setup Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"
- name: Get Current Version
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
- name: Trigger the Update Pipeline [URLsLab]
uses: aurelien-baudet/workflow-dispatch@v4
with:
workflow: update-theme.yml
repo: QualityUnit/urlslab-wp
ref: main
token: ${{ secrets.WEB_CICD_PAT }}
wait-for-completion-interval: 5s
inputs: '{
"repository":"urlslab-wp",
"version":"${{ env.PACKAGE_VERSION }}"
}'