Skip to content

Create release

Create release #4

Workflow file for this run

name: Moodle Plugin CI
on: [release]
jobs:
test:
runs-on: ubuntu-22.04
env:
PLUGIN_NAME: 'mod_adleradaptivity'
permissions:
contents: write
steps:
- name: Check out code
uses: actions/checkout@v2
- 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 -r .github tests vendor .gitignore composer.json composer.lock phpunit.xml dev_utils
- name: Create release archives
run: |
tar -czf /moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz *
zip -r /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: /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: /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: 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${{ github.event.release.body | head -n 7 }}\n..."

Check failure on line 78 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / Moodle Plugin CI

Invalid workflow file

The workflow is not valid. .github/workflows/release.yml (Line: 78, Col: 24): Unexpected symbol: '|'. Located at position 27 within expression: github.event.release.body | head -n 7