I18N Weekly Release #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v4 | |
# Use project specific node version | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
# enable dependencies caching (vendor and node_modules are wiped during build so they are ignored here) | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/composer/ | |
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} | |
- uses: actions/cache@v4 | |
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." |