Skip to content

Create release

Create release #41

Workflow file for this run

name: Moodle Plugin CI
on: [release]
jobs:
release:
runs-on: ubuntu-22.04
env:
PLUGIN_NAME: 'mod_adleradaptivity'
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 -czf /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz *
zip -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: Bump Version in main
run: |
git reset --hard
git checkout main
cli/bump_version.py && cli/bump_version.py
# append -dev to $plugin->release
sed -i "s/^\$plugin->release\s=\s'[^']*';/\$plugin->release = '${{ github.ref_name }}-dev';/" version.php
# set maturity to MATURITY_ALPHA
sed -i "s/^\$plugin->maturity\s=\sMATURITY_STABLE;/\$plugin->maturity = MATURITY_ALPHA;/" version.php
# set git user
git config --global user.email "[email protected]"
git config --global user.name "github-actions[bot]"
git add version.php
git commit -m "update version.php to ${{ github.ref_name }}-dev"
git push
- name: Prepare shortened release body
id: prep_body
run: |
SHORT_BODY=$(echo "${{ github.event.release.body }}" | head -n 7)
echo "SHORT_BODY=${SHORT_BODY}" >> $GITHUB_ENV
- name: Discord notification
uses: appleboy/discord-action@master
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
title: 'New release of ${{ github.repository }}, Version ${{ github.ref_name }}'
description: '<${{ github.event.release.html_url }}>\n\n${{ env.SHORT_BODY }}\n...'