Skip to content

Commit

Permalink
add release gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
anteprimorac committed Nov 28, 2023
1 parent 4e7d8c0 commit 560ae6e
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 1 deletion.
80 changes: 80 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Release

on:
release:
types: [published]

jobs:
test:
uses: ./.github/workflows/test.yml
secrets: inherit

publish:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# Setup GIT
- name: Setup GIT
run: git config --global user.name "OpsAgilo" && git config --global user.email "[email protected]" && git config --global credential.helper store

- name: Setup git credentials
run: echo "https://agilo:${{ secrets.WORDPRESS_PLUGIN_READ_ONLY_REPO_API_TOKEN }}@github.com" > ~/.git-credentials

# Setup Node.js and NPM
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- run: npm ci

# Setup PHP
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
coverage: none
tools: composer:"v2"

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

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php7.4-composer_v2-${{ hashFiles('wordpress-plugin/composer.lock') }}
restore-keys: ${{ runner.os }}-php7.4-composer_v2-

- run: composer install --prefer-dist --no-progress -d ./wordpress-plugin

# Build Medusa plugin
- run: npm -w medusa-plugin-wordpress run build

# Build WordPress plugin
- run: npm -w wordpress-plugin run build
- run: npm run generate:medusa-api
- run: rm -f wordpress-plugin/.gitignore
- run: mkdir wordpress-plugin/.github && cp .github/banner.png wordpress-plugin/.github/banner.png

# Publish Medusa plugin
- run: npm -w medusa-plugin-wordpress publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# Publish WordPress plugin
- run: npm run publish:wp-plugin

# Copy release to read-only repo
- name: Copy release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
repository: agilo/medusa-wp-wordpress-plugin
token: ${{ secrets.WORDPRESS_PLUGIN_READ_ONLY_REPO_API_TOKEN }}
tag_name: ${{ github.event.release.tag_name }}
name: ${{ github.event.release.name }}
15 changes: 15 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"gitdeploy": {
"wp-plugin": [
{
"target": "https://github.com/Agilo/medusa-wp-wordpress-plugin.git",
"branch": "master",
"artifactDir": "wordpress-plugin",
"cleanTargetGlob": ["**", "!.git", "!.gitignore"]
}
]
},
"jobs": {
"publish:wp-plugin": ["gitdeploy:wp-plugin"]
}
}
179 changes: 179 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
"generate:medusa-api:store": "node --no-warnings=ExperimentalWarning --loader ts-node/esm ./dev/scripts/generate-medusa-client.ts store",
"generate:medusa-api": "npm run generate:medusa-api:admin && npm run generate:medusa-api:store",
"generate:medusa-seed": "node --no-warnings=ExperimentalWarning --loader ts-node/esm ./dev/scripts/generate-medusa-seed.ts",
"generate:medusa-import-csv": "node --no-warnings=ExperimentalWarning --loader ts-node/esm ./dev/scripts/generate-medusa-import-csv.ts"
"generate:medusa-import-csv": "node --no-warnings=ExperimentalWarning --loader ts-node/esm ./dev/scripts/generate-medusa-import-csv.ts",
"publish:wp-plugin": "agilorun publish:wp-plugin --verbose"
},
"dependencies": {
"@agilorunner/gitdeploy": "^2.4.0",
"@agilorunner/run": "^2.4.0",
"@medusajs/medusa-oas-cli": "file:.yalc/@medusajs/medusa-oas-cli",
"concurrently": "^8.2.2",
"execa": "^8.0.1",
Expand Down

0 comments on commit 560ae6e

Please sign in to comment.