ignore more files #23
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | 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 wordpress-gdata-antivirus.php | sed -nE 's/^.*Version: ([0-9a-z\.\-])/\1/p') | |
echo "plugin_version=v$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 wordpress-gdata-antivirus.php | sed -nE 's/^.*Version: ([0-9a-z\.\-])/\1/p') | |
PLUGIN_VERSION_SUFFIX=${GITHUB_HEAD_REF}-${{ github.run_id }} | |
echo "plugin_version=v$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 wordpress-gdata-antivirus.php | sed -nE 's/^.*Version: ([0-9a-z\.\-])/\1/p') | |
PLUGIN_VERSION_SUFFIX=${GITHUB_REF_NAME}-${{ github.run_id }} | |
echo "plugin_version=v$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: zip it | |
run: zip wordpress-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: wordpress-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: wordpress-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 |