-
Notifications
You must be signed in to change notification settings - Fork 3
170 lines (151 loc) · 6.08 KB
/
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
name: 'release'
on:
push:
tags: [ '*' ]
jobs:
tests:
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- uses: actions/checkout@v2
id: code-checkout
- name: Validate composer.json and composer.lock
id: composer-validate
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
id: install-dependencies
uses: php-actions/composer@v5
with:
php_version: 8.0
args: --prefer-dist --no-progress --no-suggest
- name: PHP Unit Test
id: php-unit-test
uses: php-actions/phpunit@v3
with:
php_version: 8.0.27
version: 9.5.21
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#wordpress-bmlt-workflow'
if: failure()
deploy-bmlt-workflow-latest:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
env:
WORDPRESS_USERNAME: ${{ secrets.BMLTWF_WORDPRESS_USERNAME }}
WORDPRESS_PASSWORD: ${{ secrets.BMLTWF_WORDPRESS_PASSWORD }}
BUILD_DIR: build
DIST_DIR_S3: dist/s3
DIST_DIR_GITHUB: dist/github
GITHUB_RELEASE_FILENAME: bmlt-workflow.zip
S3_KEY: bmlt-workflow
PLUGIN: bmlt-workflow
MAINFILE: bmlt-workflow.php
steps:
- uses: actions/checkout@v2
id: code-checkout
- name: Validate composer.json and composer.lock
id: composer-validate
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
id: install-dependencies
run: composer install --no-dev --prefer-dist --no-progress --no-suggest
- name: Prepare zip file
run: |
export ZIP_FILENAME=${S3_KEY}-build${GITHUB_RUN_NUMBER}-${GITHUB_SHA}.zip
echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV
echo "GITHUB_RELEASE_FILENAME=${GITHUB_RELEASE_FILENAME}" >> $GITHUB_ENV
echo "GITHUB_RELEASE_PATH=${DIST_DIR_GITHUB}/${GITHUB_RELEASE_FILENAME}" >> $GITHUB_ENV
zip -r $ZIP_FILENAME ./ -x "/.git*" -x "*.editorconfig*" -x "/vendor*" -x "/mockoon/*" -x "composer.*" -x "*.github*" -x "/assets*" -x "*.gitattributes" -x "/node_modules/*" -x "/tests/*" -x ".userdetails.sh" -x ".phpunit.result.cache" -x "*.DS_Store*" -x "Dockerfile" -x "patchwork.json" -x "/.phpunit.cache*" -x "/docker/*" -x "/.vscode*" -x "phpunit.xml" -x ".testcaferc.js" -x "docker-compose.yml" -x "package.json" -x "package-lock.json" -x "phpunit.xml.orig" -x "config_phpunit.php"
mkdir $BUILD_DIR && mv $ZIP_FILENAME $BUILD_DIR/
mkdir -p $DIST_DIR_S3 && cp $BUILD_DIR/$ZIP_FILENAME $DIST_DIR_S3/$ZIP_FILENAME
mkdir -p $DIST_DIR_GITHUB && cp $BUILD_DIR/$ZIP_FILENAME $DIST_DIR_GITHUB/$GITHUB_RELEASE_FILENAME
curl -LO https://raw.githubusercontent.com/bmlt-enabled/bmlt-wordpress-deploy/master/deploy-wordpress.sh
chmod +x deploy-wordpress.sh
curl -sLO https://raw.githubusercontent.com/bmlt-enabled/release-notes-tool/master/gh-release-notes.sh
chmod +x gh-release-notes.sh
./gh-release-notes.sh CHANGELOG.md "##"
- name: Prepare artifact metadata
id: prepare_artifact_metadata
run: |
echo ::set-output name=ARTIFACT_PATH::./${GITHUB_RELEASE_PATH}
echo ::set-output name=ARTIFACT_NAME::${GITHUB_RELEASE_FILENAME}
- name: Release beta
if: contains(github.ref, 'beta')
id: beta_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
prerelease: true
draft: false
- name: Upload Beta Asset
if: contains(github.ref, 'beta')
id: beta-release-asset-wp
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.beta_release.outputs.upload_url }}
asset_path: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }}
asset_name: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }}
asset_content_type: application/zip
- name: Release stable
if: "!contains(github.ref, 'beta')"
id: stable_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: "changelog.txt"
prerelease: false
draft: false
- name: Upload Stable Asset WP
if: "!contains(github.ref, 'beta')"
id: stable-release-asset-wp
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.stable_release.outputs.upload_url }}
asset_path: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }}
asset_name: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }}
asset_content_type: application/zip
- name: Publish Release to WP
if: "!contains(github.ref, 'beta')"
id: publish-release-wp
run: |
./deploy-wordpress.sh
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#wordpress-bmlt-workflow'
if: failure()