Skip to content

Merge pull request #463 from bmlt-enabled/version-bump-did-not-includ… #97

Merge pull request #463 from bmlt-enabled/version-bump-did-not-includ…

Merge pull request #463 from bmlt-enabled/version-bump-did-not-includ… #97

Workflow file for this run

name: 'release'
on:
push:
tags: ['*']
jobs:
deploy-crouton-release:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
BUILD_DIR: build
DIST_DIR_S3_JS: dist_croutonjs/s3
DIST_DIR_S3: dist/s3
DIST_DIR_GITHUB_JS: dist_croutonjs/github
DIST_DIR_GITHUB: dist/github
GITHUB_RELEASE_FILENAME_JS: croutonjs.zip
GITHUB_RELEASE_FILENAME: crouton.zip
S3_KEY_JS: croutonjs
S3_KEY: crouton
PLUGIN: crouton
MAINFILE: crouton.php
steps:
- uses: actions/checkout@v3
id: code-checkout
- name: Prepare crouton zip file
run: |
export ZIP_FILENAME_JS=croutonjs-build${GITHUB_RUN_NUMBER}-${GITHUB_SHA}.zip
echo "ZIP_FILENAME_JS=${ZIP_FILENAME_JS}" >> $GITHUB_ENV
export ZIP_FILENAME=crouton-build${GITHUB_RUN_NUMBER}-${GITHUB_SHA}.zip
echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV
echo "GITHUB_RELEASE_FILENAME_JS=${GITHUB_RELEASE_FILENAME_JS}" >> $GITHUB_ENV
echo "GITHUB_RELEASE_FILENAME=${GITHUB_RELEASE_FILENAME}" >> $GITHUB_ENV
echo "GITHUB_RELEASE_PATH_JS=${DIST_DIR_GITHUB_JS}/${GITHUB_RELEASE_FILENAME_JS}" >> $GITHUB_ENV
echo "GITHUB_RELEASE_PATH=${DIST_DIR_GITHUB}/${GITHUB_RELEASE_FILENAME}" >> $GITHUB_ENV
find ./ -type d | xargs chmod 755
find ./ -name '*.php' | xargs chmod 644
git archive --format=zip --output=${ZIP_FILENAME} ${GITHUB_SHA}
DISABLE_NOTIFIER=true make deploy
zip -r ${ZIP_FILENAME} croutonjs/dist/*
TAG="${GITHUB_REF##*/}"
cd croutonjs/dist; zip -r ../../${ZIP_FILENAME_JS} *; cd ../../
mkdir -p $BUILD_DIR && mv $ZIP_FILENAME_JS $BUILD_DIR/ && mv $ZIP_FILENAME $BUILD_DIR/
mkdir -p $DIST_DIR_S3_JS && cp $BUILD_DIR/$ZIP_FILENAME_JS $DIST_DIR_S3_JS/$ZIP_FILENAME_JS
mkdir -p $DIST_DIR_GITHUB_JS && cp $BUILD_DIR/$ZIP_FILENAME_JS $DIST_DIR_GITHUB_JS/$GITHUB_RELEASE_FILENAME_JS
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
- name: Generate Release Notes 📝
if: github.ref_type == 'tag'
run: |
curl -LO https://raw.githubusercontent.com/bmlt-enabled/release-notes-tool/master/gh-release-notes.sh
chmod +x gh-release-notes.sh
./gh-release-notes.sh readme.txt "wp"
RELEASE_TYPE=$(if [[ "$GITHUB_REF_NAME" =~ "beta" ]]; then echo "true"; else echo "false"; fi)
echo "RELEASE_TYPE=${RELEASE_TYPE}" >> $GITHUB_ENV
- name: Create Release 🎉
uses: ncipollo/[email protected]
if: github.ref_type == 'tag'
with:
artifacts: ${{ env.GITHUB_RELEASE_PATH }},${{ env.GITHUB_RELEASE_PATH_JS }}
bodyFile: "changelog.txt"
prerelease: ${{ env.RELEASE_TYPE }}
- name: Wordpress Release ⛴
if: "!contains(github.ref, 'beta')"
id: wordpress-stable-release
env:
WORDPRESS_USERNAME : ${{ secrets.WORDPRESS_USERNAME }}
WORDPRESS_PASSWORD : ${{ secrets.WORDPRESS_PASSWORD }}
run: |
curl -LO https://raw.githubusercontent.com/bmlt-enabled/bmlt-wordpress-deploy/master/deploy-wordpress.sh
chmod +x deploy-wordpress.sh
./deploy-wordpress.sh
- name: Setup Node
if: "!contains(github.ref, 'beta')"
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Publish package on NPM 📦
if: "!contains(github.ref, 'beta')"
run: |
cp croutonjs/README.md croutonjs/dist
cd croutonjs/dist
npm --no-git-tag-version version $GITHUB_REF_NAME
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#crouton'
if: failure()