Skip to content

Apply wordpress review suggestions #44

Apply wordpress review suggestions

Apply wordpress review suggestions #44

Workflow file for this run

name: github release
on:
push:
branches: [
"main",
# this should be mainly branch releases for created issues
"[0-9]-*"
]
tags: ["*"]
pull_request:
branches: ["*"]
jobs:
get-version:
runs-on: ubuntu-latest
outputs:
plugin_version: ${{ steps.get-version.outputs.plugin_version }}
plugin_prerelease: ${{ steps.get-version.outputs.plugin_prerelease }}
steps:
- uses: actions/checkout@v4
- id: get-version
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
echo "running tag version extract"
echo "plugin_version=${GITHUB_REF_NAME#v}" | tee -a "$GITHUB_OUTPUT"
echo "plugin_prerelease=false" | tee -a "$GITHUB_OUTPUT"
elif [[ $GITHUB_REF == refs/head/main ]]; then
echo "running main version extract from file"
PLUGIN_VERSION=$(cat gdata-antivirus.php | sed -nE 's/^.*Version: ([0-9a-z\.\-])/\1/p')
echo "plugin_version=$PLUGIN_VERSION" | tee -a "$GITHUB_OUTPUT"
echo "plugin_prerelease=false" | tee -a "$GITHUB_OUTPUT"
elif [[ $GITHUB_REF == refs/pull/* ]]; then
echo "running pull request version extract from file"
PLUGIN_VERSION=$(cat gdata-antivirus.php | sed -nE 's/^.*Version: ([0-9a-z\.\-])/\1/p')
PLUGIN_VERSION_SUFFIX=${GITHUB_HEAD_REF//\//_}-${{ github.run_id }}
echo "plugin_version=$PLUGIN_VERSION-$PLUGIN_VERSION_SUFFIX" | tee -a "$GITHUB_OUTPUT"
echo "plugin_prerelease=true" | tee -a "$GITHUB_OUTPUT"
else
echo "running branch version extract from file"
PLUGIN_VERSION=$(cat gdata-antivirus.php | sed -nE 's/^.*Version: ([0-9a-z\.\-])/\1/p')
PLUGIN_VERSION_SUFFIX=${GITHUB_REF_NAME//\//_}-${{ github.run_id }}
echo "plugin_version=$PLUGIN_VERSION-$PLUGIN_VERSION_SUFFIX" | tee -a "$GITHUB_OUTPUT"
echo "plugin_prerelease=true" | tee -a "$GITHUB_OUTPUT"
fi
test:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/devcontainers/php:1-8.2-bullseye
steps:
- uses: actions/checkout@v4
- name: composer install
run: composer install
- name: phpunit
run: ./vendor/bin/phpunit --testdox tests/
build:
runs-on: ubuntu-latest
needs:
- get-version
- test
container:
image: mcr.microsoft.com/devcontainers/php:1-8.2-bullseye
steps:
- uses: actions/checkout@v4
- name: composer install
run: composer install --no-dev
- name: replace version
run: bash set-version.sh "${{needs.get-version.outputs.plugin_version}}"
- name: zip it
run: zip -r gdata-antivirus-${{needs.get-version.outputs.plugin_version}}.zip * --exclude @.zipignore
- uses: actions/upload-artifact@master
if: startsWith(github.ref, 'refs/tags/v')
with:
name: plugin-zip
path: gdata-antivirus-${{needs.get-version.outputs.plugin_version}}.zip
release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs:
- get-version
- build
steps:
- name: download artifact
uses: actions/download-artifact@master
with:
name: plugin-zip
- name: Release
uses: softprops/action-gh-release@v2
with:
files: gdata-antivirus-${{needs.get-version.outputs.plugin_version}}.zip
tag_name: ${{needs.get-version.outputs.plugin_version}}
prerelease: ${{needs.get-version.outputs.plugin_prerelease}}
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: true