-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup deployment for PHP packages (#48)
* Setup deployment for PHP packages * Create spicy-carpets-march.md * Update release.yml * Update changeset and changelog * Update README.md
- Loading branch information
1 parent
85c542c
commit 78deae9
Showing
12 changed files
with
124 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@wpsocio/telegram-format-text": major | ||
"@wpsocio/wptelegram-bot-api": major | ||
"@wpsocio/wp-utils": major | ||
--- | ||
|
||
First public release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Deploy PHP Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy PHP Package | ||
needs: [details] | ||
runs-on: ubuntu-latest | ||
if: ${{ fromJson(needs.details.outputs.result).shouldDeploy }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Environment | ||
uses: ./actions/setup | ||
with: | ||
lockfile: pnpm-hashed.lock | ||
|
||
- name: Clean up | ||
run: | | ||
# Create a temp dir and move the files to it | ||
mkdir -p temp/${{ fromJson(needs.details.outputs.result).path }} | ||
# Move only the files that are needed | ||
mv -t temp/${{ fromJson(needs.details.outputs.result).path }} composer.json src/ LICENSE README.md CHANGELOG.md .gitignore | ||
- name: Deploy to repo | ||
uses: manzoorwanijk/action-deploy-to-repo@v3 | ||
with: | ||
src_dir: temp/${{ fromJson(needs.details.outputs.result).path }} | ||
target_repo: ${{ fromJson(needs.details.outputs.result).repo }} | ||
target_dir: "." | ||
target_branch: main | ||
access_token: ${{ secrets.GH_ACCESS_TOKEN }} | ||
# Remove everything from the target repo before deploying | ||
cleanup_command: git rm -rf . && git clean -fxd | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
body: ${{ github.event.release.body }} | ||
token: ${{ secrets.GH_ACCESS_TOKEN }} | ||
tag_name: v${{ fromJson(needs.details.outputs.result).version }} | ||
repository: ${{ fromJson(needs.details.outputs.result).repo }} | ||
|
||
details: | ||
name: Get details | ||
runs-on: ubuntu-latest | ||
outputs: | ||
result: ${{ steps.details.outputs.result }} | ||
steps: | ||
- name: Get details | ||
uses: actions/github-script@v7 | ||
id: details | ||
with: | ||
script: | | ||
const tagRegex = /^(?<name>.+)@(?<version>[^@]+)$/; | ||
const result = '${{ github.event.release.tag_name }}'.match(tagRegex); | ||
if (!result?.groups?.name || !result?.groups?.version) { | ||
console.warn('Invalid tag name: "${{ github.event.release.tag_name }}"'); | ||
return { shouldDeploy: false }; | ||
} | ||
const { name, version } = result.groups; | ||
const toDeploy = [ | ||
'@wpsocio/telegram-format-text', | ||
'@wpsocio/wp-utils', | ||
'@wpsocio/wptelegram-bot-api', | ||
]; | ||
if (!toDeploy.includes(name)) { | ||
return { shouldDeploy: false }; | ||
} | ||
const path = `packages/php/${name.split('/', 2)[1]}/`; | ||
const shouldDeploy = true; | ||
const repo = name.replace('@', ''); | ||
return { name, version, path, repo, shouldDeploy }; | ||
- name: Print details | ||
run: | | ||
echo "Details: ${{ steps.details.outputs.result }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
|
||
## 0.0.1 | ||
|
||
- Initial private release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
|
||
## 0.0.1 | ||
|
||
- Initial private release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
|
||
## 0.0.1 | ||
|
||
- Initial private release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters