1.0.0 #7
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: Moodle Plugin CI | |
on: | |
release: | |
types: [created] | |
jobs: | |
release: | |
runs-on: ubuntu-22.04 | |
env: | |
PLUGIN_NAME: 'local_logging' | |
permissions: | |
contents: write | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: update release version.php | |
run: | | |
sed -i "s/^\$plugin->release\s=\s'[^']*';/\$plugin->release = '${{ github.ref_name }}';/" version.php # set release | |
cli/bump_version.py # set version | |
# set maturity to | |
# - default: MATURITY_STABLE | |
# - release is marked as pre-release on github, then MATURITY_BETA | |
# - release name contains 'rc', then MATURITY_RC | |
if [[ "${{ github.ref_name }}" == *"rc"* ]]; then | |
sed -i "s/^\$plugin->maturity\s=\sMATURITY_STABLE;/\$plugin->maturity = MATURITY_RC;/" version.php | |
elif [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" == "true" ]]; then | |
sed -i "s/^\$plugin->maturity\s=\sMATURITY_STABLE;/\$plugin->maturity = MATURITY_BETA;/" version.php | |
else | |
sed -i "s/^\$plugin->maturity\s=\sMATURITY_STABLE;/\$plugin->maturity = MATURITY_STABLE;/" version.php | |
fi | |
- name: remove files not needed for release | |
run: | | |
rm -rf .github tests vendor .gitignore composer.json composer.lock phpunit.xml dev_utils | |
- name: Create release archives | |
run: | | |
tar --exclude='.git' -czf /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz * | |
zip -x .git -r /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip * | |
- name: Upload release archives | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip | |
tag: ${{ github.ref_name }} | |
- name: Upload release archives | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz | |
tag: ${{ github.ref_name }} | |
- name: Prepare release body (description) | |
id: prep_body | |
run: | | |
echo "${{ github.event.release.body }}" > changes.md | |
- name: Discord notification | |
uses: appleboy/discord-action@master | |
with: | |
webhook_id: ${{ secrets.DISCORD_RELEASE_CHANNEL_WEBHOOK_ID }} | |
webhook_token: ${{ secrets.DISCORD_RELEASE_CHANNEL_WEBHOOK_TOKEN }} | |
username: GitHub Releases | |
message: "New release of **${{ github.repository }}**\nVersion: ${{ github.ref_name }} (${{github.event.release.name}})\n<${{ github.event.release.html_url }}>" | |
file: changes.md |