Skip to content

Commit

Permalink
Merge branch 'feature/reintroduce-packagist-deploy' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinkrzeminski committed Oct 3, 2024
2 parents e15c2ce + ec217b8 commit 12b3e1d
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ playwright.config.js
renovate.json
.git
.github
.idea
.vscode
.wordpress-org
build
dist
local
node_modules
tests
Expand Down
130 changes: 130 additions & 0 deletions .github/workflows/deploy-to-stream-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Deploy to xwp/stream-dist Repository

on:
push:
branches:
- master
- develop

jobs:
lint_and_test:
uses: ./.github/workflows/lint-and-test.yml

deploy_to_stream_dist:
needs: lint_and_test
name: Deploy to xwp/stream-dist
runs-on: ubuntu-22.04
permissions:
contents: write
packages: read

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer:v2

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer packages
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ hashFiles( 'composer.lock' ) }}
restore-keys: ${{ runner.os }}-php-

- name: Install NPM dependencies
run: npm install

- name: Install Composer dependencies
run: composer install --no-dev

- name: Build
run: npm run build

- name: Setup environment
run: |
set -ex
ROOT_DIR="$(git rev-parse --show-toplevel)"
WORKING_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
SRC_DIR="$ROOT_DIR/build"
DIST_DIR="$ROOT_DIR/dist"
DIST_BRANCH="${GITHUB_REF#refs/heads/}"
DIST_TAG="${GITHUB_REF#refs/tags/}"
COMMIT_MESSAGE="$(git log -1 --oneline)"
echo "ROOT_DIR=$ROOT_DIR" >> $GITHUB_ENV
echo "WORKING_BRANCH=$WORKING_BRANCH" >> $GITHUB_ENV
echo "SRC_DIR=$SRC_DIR" >> $GITHUB_ENV
echo "DIST_DIR=$DIST_DIR" >> $GITHUB_ENV
echo "DIST_BRANCH=$DIST_BRANCH" >> $GITHUB_ENV
echo "DIST_TAG=$DIST_TAG" >> $GITHUB_ENV
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
- name: Sync files locally
run: |
set -ex
rm -rf "$SRC_DIR"
rm -rf "$DIST_DIR"
mkdir -p "$SRC_DIR"
rsync -av --exclude-from=.distignore "$ROOT_DIR/" "$SRC_DIR/"
env:
ROOT_DIR: ${{ env.ROOT_DIR }}
SRC_DIR: ${{ env.SRC_DIR }}
DIST_DIR: ${{ env.DIST_DIR }}

- name: Setup SSH deploy key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_DEPLOY_KEY }}
known_hosts: github.com

- name: Configure Git
run: |
git config --global user.name "XWP Deploy Bot"
git config --global user.email "[email protected]"
- name: Deploy to xwp/stream-dist
run: |
set -ex
export GIT_DIR="$DIST_DIR/.git"
export GIT_WORK_TREE="$DIST_DIR"
git clone --progress --verbose ${{ vars.DIST_REPO }} "$DIST_DIR/.git"
git checkout -B "$DIST_BRANCH"
# Use the release bundle as the work tree.
export GIT_WORK_TREE="$SRC_DIR"
git add --all
git commit --allow-empty --message "$COMMIT_MESSAGE"
if [ "${{ github.event_name }}" = "release" ]; then
echo "Tagging a release: $DIST_TAG"
git tag --force "$DIST_TAG"
git push --force --tags origin "$DIST_BRANCH"
else
git push --force origin "$DIST_BRANCH"
fi
env:
DIST_DIR: ${{ env.DIST_DIR }}
DIST_BRANCH: ${{ env.DIST_BRANCH }}
DIST_TAG: ${{ env.DIST_TAG }}
COMMIT_MESSAGE: ${{ env.COMMIT_MESSAGE }}
3 changes: 3 additions & 0 deletions .github/workflows/deploy-to-wp-org.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ on:
- prereleased

jobs:
lint_and_test:
uses: ./.github/workflows/lint-and-test.yml

deploy_to_wp_repository:
needs: lint_and_test
name: Deploy to WP.org
runs-on: ubuntu-22.04
permissions:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Lint and Test

on: push
on: [push, workflow_call]

jobs:

Expand Down
40 changes: 0 additions & 40 deletions local/scripts/dist.sh

This file was deleted.

0 comments on commit 12b3e1d

Please sign in to comment.