-
Notifications
You must be signed in to change notification settings - Fork 35
Release automation #1172
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
base: develop
Are you sure you want to change the base?
Release automation #1172
Changes from all commits
977eac5
fbd9589
6bca598
e91ec4e
cf14f66
e5456e6
1b6e62f
132618d
de05f63
05d6572
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 |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ name: CI | |
|
|
||
| on: | ||
| push: | ||
| branches: [ develop, master ] | ||
| workflow_call: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| name: Deploy to WordPress.org Repository | ||
|
|
||
| on: | ||
|
|
||
| # The action will run when a release or a pre-release is created. | ||
| # | ||
| # In case of a pre-release, the action will not commit to WP.org (dry-run). However, it will still | ||
| # create a zip file and upload it to the release. Note that a pre-release (release candidate) | ||
| # should not be changed to a release but rather a new release should be created. | ||
| # | ||
| # The "prereleased" type will not trigger for pre-releases published from draft releases, but | ||
| # the "published" type will trigger. Since we want a workflow to run when stable and pre-releases | ||
| # publish, we subscribe to "published" instead of "released" and "prereleased". | ||
| # | ||
| # See: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#release | ||
| release: | ||
| types: [ published ] | ||
|
|
||
| jobs: | ||
| lint_and_test: | ||
| uses: ./.github/workflows/ci.yml | ||
|
|
||
| deploy_to_wp_repository: | ||
| needs: lint_and_test | ||
| name: Deploy to WP.org | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'npm' | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.3' | ||
| tools: composer:v2 | ||
|
|
||
| - name: Get Composer cache directory | ||
| id: composer-cache | ||
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Cache Composer packages | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ steps.composer-cache.outputs.dir }} | ||
| key: ${{ runner.os }}-php-${{ hashFiles( 'composer.lock' ) }} | ||
| restore-keys: ${{ runner.os }}-php- | ||
|
|
||
| # Install dependencies. | ||
| - name: Install NPM dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Install Composer dependencies | ||
| run: composer install --no-dev | ||
|
|
||
| # Build. | ||
| - name: Build | ||
| run: npm run build | ||
|
Contributor
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. 💬 suggestion: The release pipeline trusts that the human releaser bumped .version, package.json, and readme.txt to match the tag they're publishing. There's nothing here to fail the build if git tag == "3.3.4" but .version == "3.3.3". Given the PR explicitly notes the human has to remember to update both files, a 5-line sanity check is cheap insurance:
Collaborator
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. Good idea 👍 e5456e6 Done here |
||
|
|
||
| - name: Prepare build directory | ||
| run: npx grunt prepare | ||
|
|
||
| # Ensure the version in the .version file matches the tag of the release. | ||
| - name: Verify version matches tag | ||
| run: | | ||
| TAG="${GITHUB_REF_NAME#v}" | ||
| FILE_VERSION=$(cat .version | tr -d '[:space:]') | ||
| if [ "$TAG" != "$FILE_VERSION" ]; then | ||
| echo "::error::Tag $TAG does not match .version $FILE_VERSION" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: WordPress Plugin Deploy | ||
| # This is used to get the zip-path later. | ||
| id: deploy | ||
| uses: 10up/action-wordpress-plugin-deploy@stable | ||
| with: | ||
| generate-zip: true | ||
| # In case of a pre-release, do not commit to WP.org. | ||
| dry-run: ${{ github.event.release.prerelease }} | ||
|
|
||
| env: | ||
| BUILD_DIR: 'build' | ||
| SLUG: 'cloudinary-image-management-and-manipulation-in-the-cloud-cdn' | ||
| # Use secrets to authenticate with WP.org. | ||
| SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | ||
| SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | ||
|
|
||
| # After the deployment, we also want to create a zip and upload it to the release on GitHub. | ||
| - name: Upload release asset | ||
| uses: actions/upload-release-asset@v1 | ||
|
Contributor
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. 💡 thought: This action is archived and deprecated by GitHub since 2021. Should we migrate it to more active ones like:
Collaborator
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. @PatelUtkarsh It seems that "softprops/action-gh-release" serves a different purpose from my understanding though, no? 🤔 It seems to be aimed at creating github releases, while here we're trying to upload assets to the manually created release https://github.com/softprops/action-gh-release |
||
| env: | ||
| # Note, this is an exception to action secrets: GITHUB_TOKEN is always available and provides access to | ||
| # the current repository this action runs in. | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| with: | ||
| # Get the URL for uploading assets to the current release. | ||
| upload_url: ${{ github.event.release.upload_url }} | ||
|
|
||
| # Provide the path to the file generated in the previous step using the output. | ||
| asset_path: ${{ steps.deploy.outputs.zip-path }} | ||
|
|
||
| # Provide what the file should be named when attached to the release (plugin-name.zip) | ||
| asset_name: ${{ github.event.repository.name }}.zip | ||
|
|
||
| # Provide the file type. | ||
| asset_content_type: application/zip | ||
This file was deleted.
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.
💬 suggestion: With
push:andpull_request:andworkflow_call:here every PR push fires CI twice (once for the push event on the branch, once for the PR). This isn't introduced by this PR but theworkflow_calladdition is a good moment to audit. Suggestion (out of scope, but worth a follow-up): scopepush:tobranches: [develop, master].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.
Done 132618d