mirror of
https://hk.gh-proxy.com/https://github.com/mcp-wp/mcp-server.git
synced 2026-03-03 13:46:16 +08:00
111 lines
3.7 KiB
YAML
111 lines
3.7 KiB
YAML
name: Nightly Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags-ignore:
|
|
- nightly
|
|
|
|
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
concurrency:
|
|
# The concurrency group contains the workflow name and the branch name.
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
permissions:
|
|
contents: write
|
|
pages: write
|
|
id-token: write
|
|
|
|
jobs:
|
|
build:
|
|
name: Nightly Build
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: latest
|
|
coverage: none
|
|
tools: wp-cli
|
|
|
|
- name: Install latest version of dist-archive-command
|
|
run: wp package install wp-cli/dist-archive-command:dev-main
|
|
|
|
- name: Update version number
|
|
run: |
|
|
CURRENT_DATE=$(date +%Y.%-m.%-d)
|
|
sed -i -e "s/Version:.*/Version: 0.1.$CURRENT_DATE-${GITHUB_SHA::7}/g" ./mcp.php
|
|
|
|
- name: Create updates information
|
|
run: |
|
|
CURRENT_DATE=$(date +%Y.%m.%d)
|
|
cat > update.json <<-END
|
|
{
|
|
"id": "https://mcp-wp.github.io/mcp-server/update.json",
|
|
"slug": "mcp",
|
|
"version": "0.1.$CURRENT_DATE-${GITHUB_SHA::7}",
|
|
"url": "https://github.com/mcp-wp/mcp-server",
|
|
"package": "https://mcp-wp.github.io/mcp-server/nightly.zip",
|
|
"tested": "6.6",
|
|
"requires_php": "8.0",
|
|
"autoupdate": true
|
|
}
|
|
END
|
|
|
|
- name: Create ZIP file
|
|
run: wp dist-archive . ./mcp.zip
|
|
|
|
- name: Prepare GitHub Pages
|
|
run: |
|
|
mkdir -p _site
|
|
mv update.json _site/update.json
|
|
cp ./mcp.zip _site/nightly.zip
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
|
|
- name: Delete existing release
|
|
uses: actions/github-script@v7
|
|
with:
|
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
|
script: |
|
|
try {
|
|
const response = await github.rest.repos.getReleaseByTag({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
tag: "nightly"
|
|
});
|
|
|
|
github.rest.repos.deleteRelease({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
release_id: response.data.id,
|
|
});
|
|
} catch {}
|
|
|
|
- name: Tag current commit
|
|
run: |
|
|
git config --local user.email "swissspidy@users.noreply.github.com"
|
|
git config --local user.name "swissspidy-bot"
|
|
git push origin :refs/tags/nightly
|
|
git tag -f nightly
|
|
git push origin --tags
|
|
|
|
deploy:
|
|
name: Deployment
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|