Skip to content

Commit

Permalink
test new builds
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaudiomv committed May 31, 2024
1 parent 8b8c557 commit fe6cc7d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 107 deletions.
41 changes: 14 additions & 27 deletions .github/workflows/latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,27 @@ name: 'latest'

on:
push:
branches: [ 'unstable' ]
branches: [ 'main' ]

jobs:
lint:
runs-on: ubuntu-22.04
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Check out code 🛒
uses: actions/checkout@v4

- name: Setup PHP
- name: Setup PHP 🐫
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: "mbstring, gd, bcmath, bz2"

- name: PHPCS checker
- name: PHPCS checker 🧹
id: php-codesniffer
run: make lint

- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#bread'
if: failure()

deploy:
runs-on: ubuntu-22.04
permissions:
Expand All @@ -44,45 +37,39 @@ jobs:
PLUGIN: "bread"
needs: [ lint ]
steps:
- uses: actions/checkout@v3
- name: Check out code 🛒
uses: actions/checkout@v4
id: code-checkout

- name: Setup PHP
- name: Setup PHP 🐫
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: "mbstring, gd, bcmath, bz2"

- name: Prepare to deploy
- name: Prepare to deploy 🔧
run: |
export FILENAME=${PLUGIN}-build-${GITHUB_RUN_NUMBER}-${GITHUB_SHA}
export ZIP_FILENAME=$FILENAME.zip
echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV
PROD=1 make build
mkdir -p ${DIST_DIR_S3} && cp ${BUILD_DIR}/${ZIP_FILENAME} ${DIST_DIR_S3}/${ZIP_FILENAME}
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
- name: configure aws credentials 🪪
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions/gh-ci-s3-artifact
role-session-name: gh-actions-${{ env.PLUGIN }}
aws-region: us-east-1

- name: copy artifact to s3
- name: copy artifact to s3 🪣
run: |
aws s3 cp $DIST_DIR_S3/$ZIP_FILENAME s3://$S3_BUCKET/$S3_KEY/$ZIP_FILENAME
- name: Publish Release to Latest WP
- name: Publish Release to Latest WP 🎉
id: publish_latest
uses: bmlt-enabled/wordpress-releases-github-action@v1
uses: bmlt-enabled/wordpress-releases-github-action@v1.3
with:
file: ${{ env.DIST_DIR_S3 }}/${{ env.ZIP_FILENAME }}
s3_key: ${{ env.S3_KEY }}
aws_account_id: ${{ secrets.AWS_ACCOUNT_ID }}

- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#bread'
if: failure()
9 changes: 5 additions & 4 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ name: 'pull-request'

on:
pull_request:
branches: [ 'unstable' ]
branches: [ 'main' ]

jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Check out code 🛒
uses: actions/checkout@v4
id: code-checkout

- name: Setup PHP
Expand All @@ -17,10 +18,10 @@ jobs:
php-version: 8.2
extensions: "mbstring, gd, bcmath, bz2"

- name: Validate composer.json and composer.lock
- name: Validate composer.json and composer.lock 🎼
id: composer-validate
run: composer validate

- name: PHPCS checker
- name: PHPCS checker 🧹
id: php-codesniffer
run: make lint
103 changes: 28 additions & 75 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,19 @@ jobs:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Check out code 🛒
uses: actions/checkout@v4

- name: Setup PHP
- name: Setup PHP 🐫
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: "mbstring, gd, bcmath, bz2"

- name: PHPCS checker
- name: PHPCS checker 🧹
id: php-codesniffer
run: make lint

- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#bread'
if: failure()

package:
runs-on: ubuntu-22.04
env:
Expand All @@ -39,89 +32,49 @@ jobs:
PLUGIN: "bread"
MAINFILE: "bmlt-meeting-list.php"
needs: [ lint ]
permissions:
contents: write
steps:
- uses: actions/checkout@v3
id: code-checkout

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: "mbstring, gd, bcmath, bz2"
- name: Check out code 🛒
uses: actions/checkout@v4

- name: Build package
- name: Build package 🔧
id: build-package
run: |
export ZIP_FILENAME=${PLUGIN}-build${GITHUB_RUN_NUMBER}-${GITHUB_SHA}.zip
export ZIP_FILENAME=${PLUGIN}-${GITHUB_REF##*/}.zip
find ./ -type d | xargs chmod 755
find ./ -name '*.php' | xargs chmod 644
echo ${GITHUB_SHA} > build.txt
PROD=1 make build
zip $ZIP_FILENAME build.txt
mv $ZIP_FILENAME ${PLUGIN}-${GITHUB_REF##*/}.zip
zip $BUILD_DIR/$ZIP_FILENAME build.txt
mkdir -p $DIST_DIR_GITHUB && cp $BUILD_DIR/$ZIP_FILENAME $DIST_DIR_GITHUB/$GITHUB_RELEASE_FILENAME
echo "ARTIFACT_PATH=$DIST_DIR_GITHUB/$GITHUB_RELEASE_FILENAME" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${ZIP_FILENAME}" >> $GITHUB_ENV
- 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"
curl -LO https://raw.githubusercontent.com/bmlt-enabled/bmlt-wordpress-deploy/master/deploy-wordpress.sh
chmod +x deploy-wordpress.sh
echo "ARTIFACT_PATH=./${PLUGIN}-${GITHUB_REF##*/}.zip" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${PLUGIN}-${GITHUB_REF##*/}.zip" >> $GITHUB_ENV
RELEASE_TYPE=$(if [[ "$GITHUB_REF_NAME" =~ "beta" ]]; then echo "true"; else echo "false"; fi)
echo "RELEASE_TYPE=${RELEASE_TYPE}" >> $GITHUB_ENV
- name: Release beta
if: contains(github.ref, 'beta')
id: beta_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release 🎉
uses: ncipollo/[email protected]
if: github.ref_type == 'tag'
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
prerelease: true
draft: false
artifacts: ${{ env.ARTIFACT_PATH }}
bodyFile: "changelog.txt"
prerelease: ${{ env.RELEASE_TYPE }}

- name: Upload Beta Asset
if: contains(github.ref, 'beta')
id: beta-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.beta_release.outputs.upload_url }}
asset_path: ${{ env.ARTIFACT_PATH }}
asset_name: ${{ env.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
if: "!contains(github.ref, 'beta')"
id: stable-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.stable_release.outputs.upload_url }}
asset_path: ${{ env.ARTIFACT_PATH }}
asset_name: ${{ env.ARTIFACT_NAME }}
asset_content_type: application/zip

- name: Wordpress Release
- 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $(ZIP_FILE): $(VENDOR_AUTOLOAD)
git archive --format=zip --output=${ZIP_FILENAME} $(COMMIT)
$(shell ./simplify-mpdf.sh)
zip -r ${ZIP_FILENAME} mpdf/
mkdir ${BUILD_DIR} && mv ${ZIP_FILENAME} ${BUILD_DIR}/
mkdir -p ${BUILD_DIR} && mv ${ZIP_FILENAME} ${BUILD_DIR}/

.PHONY: build
build: $(ZIP_FILE) ## Build
Expand Down

0 comments on commit fe6cc7d

Please sign in to comment.