|
| 1 | +name: Release plugin |
| 2 | + |
| 3 | +# This repository IS the plugin: the packaged files sit at its root, so there |
| 4 | +# is nothing to build here. Pushing a version tag will: |
| 5 | +# 1. Verify the tag matches the plugin header, PAPO_VERSION and Stable tag |
| 6 | +# 2. Deploy to the WordPress.org SVN repository, listing assets included |
| 7 | +# 3. Attach the installable zip to a GitHub release |
| 8 | +# |
| 9 | +# Development happens in the product-options monorepo; scripts/publish-woo-repo.sh |
| 10 | +# syncs a release state here and pushes the tag that starts this workflow. |
| 11 | +# |
| 12 | +# Required repository secrets (Settings > Secrets and variables > Actions): |
| 13 | +# SVN_USERNAME -> printapp (case sensitive, NOT the email address) |
| 14 | +# SVN_PASSWORD -> the SVN-specific password from |
| 15 | +# https://profiles.wordpress.org/printapp/profile/edit/group/3/?screen=svn-password |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + tags: |
| 20 | + - 'v*' # e.g. v0.4.0 |
| 21 | + - '[0-9]+.[0-9]+.[0-9]+' # e.g. 0.4.0 |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: write # required to create the GitHub release |
| 25 | + |
| 26 | +jobs: |
| 27 | + release: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Derive version from tag |
| 33 | + id: version |
| 34 | + run: | |
| 35 | + TAG="${GITHUB_REF_NAME}" |
| 36 | + echo "version=${TAG#v}" >> "$GITHUB_OUTPUT" |
| 37 | +
|
| 38 | + # Stable tag is what the directory actually serves. If it disagrees with |
| 39 | + # the code the release "succeeds" while users keep downloading the old |
| 40 | + # build, so this is a hard failure rather than a warning. |
| 41 | + - name: Verify tag matches plugin version |
| 42 | + run: | |
| 43 | + PLUGIN=print-app-product-options-for-woocommerce.php |
| 44 | + HEADER=$(grep -oiP '^\s*\*\s*Version:\s*\K[0-9A-Za-z.\-]+' "$PLUGIN" | head -n1) |
| 45 | + CONST=$(grep -oP "PAPO_VERSION',\s*'\K[0-9A-Za-z.\-]+" "$PLUGIN" | head -n1) |
| 46 | + STABLE=$(grep -oiP '^Stable tag:\s*\K[0-9A-Za-z.\-]+' readme.txt | head -n1) |
| 47 | + WANT="${{ steps.version.outputs.version }}" |
| 48 | + echo "tag: $WANT | header: $HEADER | PAPO_VERSION: $CONST | Stable tag: $STABLE" |
| 49 | + FAIL=0 |
| 50 | + [ "$HEADER" = "$WANT" ] || { echo "::error::Plugin header ($HEADER) != tag ($WANT)"; FAIL=1; } |
| 51 | + [ "$CONST" = "$WANT" ] || { echo "::error::PAPO_VERSION ($CONST) != tag ($WANT)"; FAIL=1; } |
| 52 | + [ "$STABLE" = "$WANT" ] || { echo "::error::Stable tag ($STABLE) != tag ($WANT)"; FAIL=1; } |
| 53 | + exit $FAIL |
| 54 | +
|
| 55 | + # ASSETS_DIR is .wordpress-org, NOT assets/ — this plugin ships its own |
| 56 | + # assets/ folder (the widget and builder bundles), and pointing the |
| 57 | + # listing assets at that name would upload the wrong files to the |
| 58 | + # plugin page. What reaches trunk is filtered by .distignore. |
| 59 | + - name: Deploy to WordPress.org SVN |
| 60 | + id: deploy |
| 61 | + uses: 10up/action-wordpress-plugin-deploy@stable |
| 62 | + with: |
| 63 | + generate-zip: true |
| 64 | + env: |
| 65 | + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
| 66 | + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
| 67 | + SLUG: print-app-product-options-for-woocommerce |
| 68 | + VERSION: ${{ steps.version.outputs.version }} |
| 69 | + ASSETS_DIR: .wordpress-org |
| 70 | + |
| 71 | + - name: Create GitHub release |
| 72 | + uses: softprops/action-gh-release@v2 |
| 73 | + with: |
| 74 | + name: Print Options for WooCommerce ${{ steps.version.outputs.version }} |
| 75 | + generate_release_notes: true |
| 76 | + files: ${{ steps.deploy.outputs.zip-path }} |
0 commit comments