Skip to content

Commit

Permalink
add release pipeline, update push/pull request pipeline triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
Glutamat42 authored Jan 16, 2024
1 parent a4616aa commit 9f531be
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Moodle Plugin CI

on: [push, pull_request]
on:
push:
branches:
- '**' # This includes all branches
tags-ignore:
- '**' # This excludes all tags
pull_request:
branches:
- '**'

jobs:
test:
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Moodle Plugin CI

on:
release:
types: [created]

jobs:
release:
runs-on: ubuntu-22.04
env:
PLUGIN_NAME: 'local_adler'
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

0 comments on commit 9f531be

Please sign in to comment.