name: Release package
on:
push:
workflow_dispatch:
env:
DC_TYPE: plugin
DC_MIN: 2.32
# required to set secrets in
# https://github.com/xxx/xxx/settings/secrets/actions
# TELEGRAM_ID, TELEGRAM_TOKEN
jobs:
check_release:
if: (contains(github.event.head_commit.message, 'release') || (github.event_name != 'push'))
runs-on: ubuntu-latest
outputs:
version: ${{ steps.dotclear.outputs.version }}
dcmin: ${{ steps.dotclear.outputs.dcmin }}
exists: ${{ steps.repository.outputs.release-exists }}
steps:
- name: Checkout repository master branch
uses: actions/checkout@master
# Parser from https://github.com/franck-paul
- name: Run PHP code
id: dotclear
shell: php {0}
run: |
> $GITHUB_OUTPUT
# Parser from https://github.com/franck-paul
- name: Read dcstore
id: readstore
shell: php {0}
run: |
(.*?)<\/version>/s',"${{ needs.check_release.outputs.version }}",$ds);
$ds = preg_replace('/(.*?)<\/file>/s',"${{ steps.download.outputs.download-url }}",$ds);
$ds = preg_replace('/(.*?)<\/da:dcmin>/s',"${{ needs.check_release.outputs.dcmin }}",$ds);
if ($ds) {
file_put_contents('dcstore.xml',$ds);
}
}
}
- name: Write dcstore
id: writestore
shell: bash
run: |
test=$(git diff --name-only -- dcstore.xml)
if [[ "$test" != "" ]]; then
echo "dcstore.xml modified, need to be commit"
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
git add dcstore.xml
git commit -m "Update dcstore.xml"
git push
else
echo "dcstore.xml not modified"
fi
- name: Create archive
id: writearchive
uses: thedoctor0/zip-release@0.7.6
with:
type: 'zip'
directory: ..
path: '${{ steps.repository.outputs.repository-name }}'
filename: '${{ env.DC_TYPE }}-${{ steps.repository.outputs.repository-name }}.zip'
exclusions: '*.git* /*node_modules/* .editorconfig'
- name: Create release with archive
id: writerelease
uses: ncipollo/release-action@v1.14.0
with:
artifacts: '../${{ env.DC_TYPE }}-${{ steps.repository.outputs.repository-name }}.zip'
token: ${{ secrets.GITHUB_TOKEN }}
commit: master
draft: false
prerelease: false
generateReleaseNotes: true
name: ${{ steps.repository.outputs.repository-name }} ${{ needs.check_release.outputs.version }}
tag: 'v${{ needs.check_release.outputs.version }}'
- name: Send Telegram Message Ok
uses: appleboy/telegram-action@v1.0.0
with:
to: ${{ secrets.TELEGRAM_ID }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
__Github workflow run__
- Trigger: ${{ github.event_name }}
- Release: ${{ steps.repository.outputs.repository-name }} ${{ needs.check_release.outputs.version }}
- Download URL: ${{ steps.download.outputs.download-url }}