|
| 1 | +name: Create Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + plugin_slug: |
| 7 | + description: 'The slug of the plugin to release' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + ref: |
| 11 | + description: 'Git Commit Reference (branch, tag, or hash)' |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + |
| 15 | + secrets: |
| 16 | + GITHUB_TOKEN: |
| 17 | + description: 'Github auth token' |
| 18 | + required: true |
| 19 | + AWS_ACCESS_KEY_ID: |
| 20 | + description: 'AWS Access Key ID' |
| 21 | + required: true |
| 22 | + AWS_SECRET_ACCESS_KEY: |
| 23 | + description: 'AWS Access Key Secret' |
| 24 | + required: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + release: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - name: Get Plugin Version |
| 31 | + id: plugin_version |
| 32 | + shell: bash |
| 33 | + run: | |
| 34 | + echo "VER=$(grep "Version:" *.php | head -1 | awk '{print $NF}')" >> $GITHUB_OUTPUT |
| 35 | +
|
| 36 | + - name: Get Minimum WP Version |
| 37 | + id: min_wp_version |
| 38 | + shell: bash |
| 39 | + run: | |
| 40 | + echo "VER=$(grep "Requires at least:" *.php | head -1 | awk '{print $NF}')" >> $GITHUB_OUTPUT |
| 41 | +
|
| 42 | + - name: Get Minimum PHP Version |
| 43 | + id: min_php_version |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + echo "VER=$(grep "Requires PHP:" *.php | head -1 | awk '{print $NF}')" >> $GITHUB_OUTPUT |
| 47 | +
|
| 48 | + - name: Generate plugin zip file |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + rsync -rc --exclude-from="${{github.workspace}}/.distignore" "${{github.workspace}}/" ${{inputs.plugin_slug}}/ --delete --delete-excluded |
| 52 | + zip -r ${{inputs.plugin_slug}}.zip ${{inputs.plugin_slug}}/ |
| 53 | +
|
| 54 | + - name: Create Release |
| 55 | + id: create_release |
| 56 | + uses: actions/create-release@v1 |
| 57 | + env: |
| 58 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + with: |
| 60 | + tag_name: ${{ steps.plugin_version.outputs.VER }} |
| 61 | + release_name: Release v${{ steps.plugin_version.outputs.VER }} |
| 62 | + draft: false |
| 63 | + prerelease: false |
| 64 | + target_commitish: ${{ inputs.ref }} |
| 65 | + |
| 66 | + - name: Upload Release Asset |
| 67 | + id: upload-release-asset |
| 68 | + uses: actions/upload-release-asset@v1 |
| 69 | + env: |
| 70 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + with: |
| 72 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 73 | + asset_path: ${{inputs.plugin_slug}}.zip |
| 74 | + asset_name: ${{ inputs.plugin_slug }}.zip |
| 75 | + asset_content_type: application/zip |
| 76 | + |
| 77 | + - name: Upload to S3 |
| 78 | + env: |
| 79 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 80 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + aws s3 cp --region us-east-1 ${{ inputs.plugin_slug }}.zip s3://downloads.ithemes.com/products/plugins/${{ inputs.plugin_slug }}/${{ inputs.plugin_slug }}-${{ steps.plugin_version.outputs.VER }}.zip |
| 84 | + aws s3 cp --region us-east-1 ${{ inputs.plugin_slug }}.zip s3://downloads.ithemes.com/products/plugins/${{ inputs.plugin_slug }}/${{ inputs.plugin_slug }}.zip |
| 85 | +
|
| 86 | + - name: Deploy to API |
| 87 | + uses: fjogeleit/http-request-action@v1 |
| 88 | + with: |
| 89 | + url: 'https://api.ithemes.com/product/deploy_plugin_update' |
| 90 | + method: 'POST' |
| 91 | + customHeaders: '{"Authorization": "${{ secrets.PLUGIN_DEPLOY_KEY }}"}' |
| 92 | + data: '{"slug": "${{ inputs.plugin_slug }}", "version": "${{ steps.plugin_version.outputs.VER }}", "min_wp_version": "${{ steps.min_wp_version.outputs.VER }}", "min_php_version": "${{ steps.min_php_version.outputs.VER }}"}' |
| 93 | + preventFailureOnNoResponse: true |
0 commit comments