-
Notifications
You must be signed in to change notification settings - Fork 112
Add trunk-only deploys #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a1a5f7
36dcb70
c966a23
1864040
5f64119
b989c5e
42a41cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,12 +67,23 @@ if [[ -z "$SLUG" ]]; then | |
| fi | ||
| echo "ℹ︎ SLUG is $SLUG" | ||
|
|
||
| # Allow setting custom version number in advanced workflows | ||
| if [[ -z "$VERSION" ]]; then | ||
| # Allow setting custom version number in advanced workflows. | ||
| # By default, only derive VERSION from tag refs; branch refs will | ||
| # result in an empty VERSION so we can support trunk-only deployments. | ||
| if [[ -z "$VERSION" && "$GITHUB_REF" == refs/tags/* ]]; then | ||
| VERSION="${GITHUB_REF#refs/tags/}" | ||
| VERSION="${VERSION#v}" | ||
| fi | ||
| echo "ℹ︎ VERSION is $VERSION" | ||
| if [[ -n "$VERSION" ]]; then | ||
| echo "ℹ︎ VERSION is $VERSION" | ||
| else | ||
| echo "ℹ︎ VERSION is not set; trunk-only deployment assumed unless overridden." | ||
| fi | ||
|
|
||
| # Cast to empty string when not set for easier -n checks. | ||
| if [[ "$INPUT_TRUNK_ONLY" != "true" ]]; then | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid repeating |
||
| INPUT_TRUNK_ONLY="" | ||
| fi | ||
|
|
||
| if [[ -z "$ASSETS_DIR" ]]; then | ||
| ASSETS_DIR=".wordpress-org" | ||
|
|
@@ -118,7 +129,9 @@ generate_zip() { | |
| } | ||
|
|
||
| # Bail early if the plugin version is already published. | ||
| if [[ -d "tags/$VERSION" ]]; then | ||
| # Only relevant when we are creating a new tag, not for | ||
| # trunk-only deployments where VERSION may be empty. | ||
| if [[ -n "$VERSION" && -d "tags/$VERSION" && -z "$INPUT_TRUNK_ONLY" ]]; then | ||
| echo "ℹ︎ Version $VERSION of plugin $SLUG was already published"; | ||
|
|
||
| generate_zip | ||
|
|
@@ -203,9 +216,12 @@ svn add . --force > /dev/null | |
| # Also suppress stdout here | ||
| svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm %@ > /dev/null | ||
|
|
||
| # Copy tag locally to make this a single commit | ||
| echo "➤ Copying tag..." | ||
| svn cp "trunk" "tags/$VERSION" | ||
| # Copy tag locally to make this a single commit when not | ||
| # doing a trunk-only deployment. | ||
| if [[ -n "$VERSION" && -z "$INPUT_TRUNK_ONLY" ]]; then | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the core change -- we only add a tag if this is not a trunk-only release. |
||
| echo "➤ Copying tag..." | ||
| svn cp "trunk" "tags/$VERSION" | ||
| fi | ||
|
|
||
| # Fix screenshots getting force downloaded when clicking them | ||
| # https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/ | ||
|
|
@@ -231,7 +247,13 @@ if $INPUT_DRY_RUN; then | |
| echo "➤ Dry run: Files not committed." | ||
| else | ||
| echo "➤ Committing files..." | ||
| svn commit -m "Update to version $VERSION from GitHub" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" | ||
|
|
||
| COMMIT_MSG="Update from GitHub" | ||
| if [[ -n "$VERSION" && -z "$INPUT_TRUNK_ONLY" ]]; then | ||
| COMMIT_MSG="Update to version $VERSION from GitHub" | ||
| fi | ||
|
|
||
| svn commit -m "$COMMIT_MSG" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" | ||
| fi | ||
|
|
||
| generate_zip | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Deploy readme and assets to WordPress.org | ||
| on: | ||
| push: | ||
| branches: | ||
| # Or use your primary branch name, e.g. main, trunk, master | ||
| - main | ||
| tags: | ||
| # On all tags. | ||
| jobs: | ||
| trunk_only_deploy: | ||
| name: Trunk-only deploy | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| # Optional build step; remove or customize as needed. | ||
| - name: Build | ||
| run: | | ||
| npm install | ||
| npm run build | ||
| # Deploy to both tags and trunk on tag, or only to trunk on main branch. | ||
| - name: WordPress Plugin Deploy | ||
| uses: 10up/action-wordpress-plugin-deploy@stable | ||
| with: | ||
| trunk-only: ${{ github.ref_name == 'main' }} | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we use the same deploy step on both branch and tag runs:
|
||
| env: | ||
| SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | ||
| SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attempt to resolve the version from tag name only if this is a tag CI run.