From 9f531bee5bfd21c201dff523d4d19cc8d9b976a6 Mon Sep 17 00:00:00 2001 From: Markus Heck <51326311+Glutamat42@users.noreply.github.com> Date: Tue, 16 Jan 2024 14:50:25 +0100 Subject: [PATCH] add release pipeline, update push/pull request pipeline triggers --- .github/workflows/moodle-ci.yml | 10 ++++- .github/workflows/release.yml | 68 +++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index 213d113..e7bfb91 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -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: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1f30337 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 \ No newline at end of file