-
Notifications
You must be signed in to change notification settings - Fork 69
121 lines (97 loc) · 3.94 KB
/
i18n-weekly-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
name: I18N Weekly Release
on:
schedule:
- cron: '0 20 * * 0'
jobs:
i18n-release:
name: Release
runs-on: ubuntu-latest
steps:
# clone the repository
- uses: actions/checkout@v3
# Use project specific node version
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
# enable dependencies caching (vendor and node_modules are wiped during build so they are ignored here)
- uses: actions/cache@v3
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
- uses: actions/cache@v3
with:
path: ~/.npm/
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
# setup PHP, but without debug extensions for reasonable performance
- name: "Set up PHP"
uses: ./.github/actions/setup-php
- name: Build release
run: |
npm ci
npm run build
if [[ ! -f woocommerce-payments.zip ]]; then
echo "Failed to create release zip"
exit 1
fi
- name: Upload release
run: |
TAG="i18n-$(date +%Y%m%d)"
NAME="Version for internationalization testing $TAG. Not for production."
BODY='This version is intended to test the internationalization strings. It should NOT be used for production.'
CREATE_RELEASE_OUT=$(mktemp)
echo "Creating i18n release..."
http_code=$(curl --request POST \
--header 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \
--header 'Content-Type: application/json' \
--data "{\"tag_name\":\"$TAG\",\"target_commitish\":\"develop\",\"name\":\"$NAME\",\"body\":\"$BODY\",\"prerelease\":true}" \
--silent \
--output "$CREATE_RELEASE_OUT" \
--write-out "%{http_code}" \
https://api.github.com/repos/Automattic/woocommerce-payments/releases)
response=$(cat "$CREATE_RELEASE_OUT")
rm "$CREATE_RELEASE_OUT"
if [[ ${http_code} -lt 200 || ${http_code} -gt 299 ]]; then
echo "Could not create release:"
echo "$response"
exit 1
fi
echo "Release created."
echo "Uploading i18n assets to GitHub Release..."
upload_url=$(echo $response | grep 'upload_url' | sed 's|.*"upload_url": "\([^{]*\).*|\1|')
if [[ -z $upload_url ]]; then
echo "No upload URL found in response:"
echo "$response"
exit 1
fi
UPLOAD_RELEASE_OUT=$(mktemp)
http_code=$(curl --request POST \
--header 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \
--header 'Content-Type: application/zip' \
--data-binary @woocommerce-payments.zip \
--silent \
--output "$UPLOAD_RELEASE_OUT" \
--write-out "%{http_code}" \
"${upload_url}?name=woocommerce-payments.zip")
response=$(cat "$UPLOAD_RELEASE_OUT")
rm "$UPLOAD_RELEASE_OUT"
if [[ ${http_code} -lt 200 || ${http_code} -gt 299 ]]; then
echo "Could not upload plugin zip to GitHub release:"
echo "$response"
exit 1
fi
echo "Assets uploaded."
echo "Triggering translations update on GlotPress..."
TRIGGER_UPLOAD_OUT=$(mktemp)
http_code=$(curl --request POST \
--silent \
--output "$TRIGGER_UPLOAD_OUT" \
--write-out "%{http_code}" \
${{ secrets.GLOTPRESS_IMPORT_URL }}/$TAG)
response=$(cat "$TRIGGER_UPLOAD_OUT")
rm "$TRIGGER_UPLOAD_OUT"
if [[ ${http_code} -lt 200 || ${http_code} -gt 299 ]]; then
echo "Could not trigger translations:"
echo "$response"
exit 1
fi
echo "Translations update triggered."