-
Notifications
You must be signed in to change notification settings - Fork 2
chore: Initial PR for creating pre-release tags for a plugin #273
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9efa56c
Initial update of the previews plugin package.json for changsets.
colinmurphy 8b3fee2
Fix changeset syntax error.
colinmurphy f2754dd
Removed ignore directories as not required.
colinmurphy 4e353d3
Added Changeset
colinmurphy 1f61f66
Fixing main package-lock.json file to get e2e tests to run.
colinmurphy 90d2934
Merge branch 'chore-setup-release-workflow-iteration-1' of github.com…
colinmurphy c427ec3
Setup of docs and starting to create release process.
colinmurphy 1b418ab
Added GH workflow for plugin releases etc. No idea until we test it w…
colinmurphy 9d59dd5
Fixed npm issue. Updated e2e test to use cached composer directory fo…
colinmurphy ebb0eeb
Added Changeset
colinmurphy 62a8db4
Delete .changeset/warm-dolphins-brake.md
colinmurphy 01401d2
Small typo fix.
colinmurphy 8fa9253
Merge branch 'chore-setup-release-workflow-iteration-1' of github.com…
colinmurphy d6322d1
Simplifying PR as we only need pre-release tags not a full release pr…
colinmurphy 3c90f66
Fixes and inlucde updating the changeset version of the plugin.
colinmurphy 9706b07
Fixes.
colinmurphy ea2411a
Reverted deleting package-lock.json as it is needed for e2e tests.
colinmurphy 69cdb6a
Updated package name. Thanks @theodesp . Updated logic of pre-release…
colinmurphy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,6 @@ | ||
| --- | ||
| "@hwp-previews/wordpress-plugin": patch | ||
| --- | ||
|
|
||
| chore: Initial release of hwp-previews beta release. | ||
|
|
This file contains hidden or 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 hidden or 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,146 @@ | ||
| name: Pre-release Tag | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - "plugins/**" | ||
|
|
||
| permissions: | ||
| contents: write # Allow actions to read and write repository contents | ||
| actions: read # Allow actions to read repository metadata but not write | ||
| jobs: | ||
| tag-pre-release: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.2' | ||
| extensions: mbstring, json, zip | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 18.x | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v3 | ||
| with: | ||
| version: 8 | ||
|
|
||
| - name: Get changed plugin directory | ||
| id: plugin | ||
| run: | | ||
| git fetch --prune --unshallow | ||
| plugin=$(git diff --name-only HEAD~1 HEAD | grep '^plugins/' | head -1 | cut -d/ -f2) | ||
| echo "plugin_slug=$plugin" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Validate plugin detection | ||
| run: | | ||
| if [ -z "${{ steps.plugin.outputs.plugin_slug }}" ]; then | ||
| echo "No plugin detected in changes" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -d "plugins/${{ steps.plugin.outputs.plugin_slug }}" ]; then | ||
| echo "Plugin directory does not exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Apply version bumps from changesets | ||
| run: pnpm changeset version | ||
|
|
||
| - name: Commit updated package.json and changelogs | ||
| run: | | ||
| git config user.name "github-actions" | ||
| git config user.email "github-actions@github.com" | ||
| git add . | ||
| git commit -m "chore: apply version bump from changesets" || echo "No changes to commit" | ||
| git push | ||
|
|
||
| - name: Read package metadata | ||
| id: metadata | ||
| run: | | ||
| PLUGIN_DIR="plugins/${{ steps.plugin.outputs.plugin_slug }}" | ||
|
|
||
| if [ ! -f "$PLUGIN_DIR/package.json" ]; then | ||
| echo "package.json not found in $PLUGIN_DIR" | ||
| exit 1 | ||
| fi | ||
|
|
||
| package_name=$(jq -r '.name // empty' "$PLUGIN_DIR/package.json") | ||
| package_version=$(jq -r '.version // empty' "$PLUGIN_DIR/package.json") | ||
|
|
||
| if [ -z "$package_name" ] || [ "$package_name" = "null" ] || [ "$package_name" = "empty" ]; then | ||
| echo "Missing or invalid name in $PLUGIN_DIR/package.json" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$package_version" ] || [ "$package_version" = "null" ] || [ "$package_version" = "empty" ]; then | ||
| echo "Missing or invalid version in $PLUGIN_DIR/package.json" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "package_name=$package_name" >> $GITHUB_OUTPUT | ||
| echo "package_version=$package_version" >> $GITHUB_OUTPUT | ||
| echo "PLUGIN_DIR=$PLUGIN_DIR" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Create Git tag | ||
| run: | | ||
| TAG_NAME="${{ steps.metadata.outputs.package_name }}-${{ steps.metadata.outputs.package_version }}" | ||
|
|
||
| # Check if tag already exists | ||
| if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then | ||
| echo "Tag $TAG_NAME already exists. Skipping tag creation." | ||
| exit 0 | ||
| fi | ||
|
|
||
| git config user.name "github-actions" | ||
| git config user.email "github-actions@github.com" | ||
| git tag "$TAG_NAME" | ||
| git push origin "$TAG_NAME" | ||
|
|
||
| - name: Run composer install | ||
| working-directory: ${{ steps.metadata.outputs.PLUGIN_DIR }} | ||
| run: composer install --no-dev --optimize-autoloader | ||
|
|
||
| - name: Validate composer setup | ||
| working-directory: ${{ steps.metadata.outputs.PLUGIN_DIR }} | ||
| run: | | ||
| composer validate --no-check-publish --no-check-lock | ||
|
|
||
| - name: Create plugin archive | ||
| working-directory: ${{ steps.metadata.outputs.PLUGIN_DIR }} | ||
| run: | | ||
| mkdir -p plugin-build | ||
| composer archive --format=zip --file="plugin-build/${{ steps.plugin.outputs.plugin_slug }}.zip" | ||
|
|
||
| # Verify archive was created | ||
| if [ ! -f "plugin-build/${{ steps.plugin.outputs.plugin_slug }}.zip" ]; then | ||
| echo "Failed to create plugin archive" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Archive created successfully: $(ls -lh plugin-build/${{ steps.plugin.outputs.plugin_slug }}.zip)" | ||
|
|
||
| - name: Upload archive to GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ steps.metadata.outputs.package_name }}-${{ steps.metadata.outputs.package_version }} | ||
| name: "Pre-release ${{ steps.metadata.outputs.package_version }} for ${{ steps.metadata.outputs.package_name }}" | ||
| prerelease: true | ||
| files: | | ||
| ${{ steps.metadata.outputs.PLUGIN_DIR }}/plugin-build/${{ steps.plugin.outputs.plugin_slug }}.zip | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.