Skip to content

Commit

Permalink
Switch to a workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyBJacobs committed Oct 7, 2023
1 parent 01298e7 commit 4fc6ea4
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 78 deletions.
78 changes: 0 additions & 78 deletions .github/actions/create-release/action.yml

This file was deleted.

93 changes: 93 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Create Release

on:
workflow_call:
inputs:
plugin_slug:
description: 'The slug of the plugin to release'
required: true
type: string
ref:
description: 'Git Commit Reference (branch, tag, or hash)'
required: true
type: string

secrets:
GITHUB_TOKEN:
description: 'Github auth token'
required: true
AWS_ACCESS_KEY_ID:
description: 'AWS Access Key ID'
required: true
AWS_SECRET_ACCESS_KEY:
description: 'AWS Access Key Secret'
required: true

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Get Plugin Version
id: plugin_version
shell: bash
run: |
echo "VER=$(grep "Version:" *.php | head -1 | awk '{print $NF}')" >> $GITHUB_OUTPUT
- name: Get Minimum WP Version
id: min_wp_version
shell: bash
run: |
echo "VER=$(grep "Requires at least:" *.php | head -1 | awk '{print $NF}')" >> $GITHUB_OUTPUT
- name: Get Minimum PHP Version
id: min_php_version
shell: bash
run: |
echo "VER=$(grep "Requires PHP:" *.php | head -1 | awk '{print $NF}')" >> $GITHUB_OUTPUT
- name: Generate plugin zip file
shell: bash
run: |
rsync -rc --exclude-from="${{github.workspace}}/.distignore" "${{github.workspace}}/" ${{inputs.plugin_slug}}/ --delete --delete-excluded
zip -r ${{inputs.plugin_slug}}.zip ${{inputs.plugin_slug}}/
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.plugin_version.outputs.VER }}
release_name: Release v${{ steps.plugin_version.outputs.VER }}
draft: false
prerelease: false
target_commitish: ${{ inputs.ref }}

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{inputs.plugin_slug}}.zip
asset_name: ${{ inputs.plugin_slug }}.zip
asset_content_type: application/zip

- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
shell: bash
run: |
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
aws s3 cp --region us-east-1 ${{ inputs.plugin_slug }}.zip s3://downloads.ithemes.com/products/plugins/${{ inputs.plugin_slug }}/${{ inputs.plugin_slug }}.zip
- name: Deploy to API
uses: fjogeleit/http-request-action@v1
with:
url: 'https://api.ithemes.com/product/deploy_plugin_update'
method: 'POST'
customHeaders: '{"Authorization": "${{ secrets.PLUGIN_DEPLOY_KEY }}"}'
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 }}"}'
preventFailureOnNoResponse: true

0 comments on commit 4fc6ea4

Please sign in to comment.