Skip to content

Commit

Permalink
Merge pull request #34 from learnweb/update/m400
Browse files Browse the repository at this point in the history
CI: Update for Moodle 4.0; Add Release Workflow
  • Loading branch information
Laur0r committed Apr 21, 2022
2 parents eefbb42 + 8d66161 commit 1187a59
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 9 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,29 @@ jobs:
static:
runs-on: ubuntu-latest

outputs:
has_tests: ${{ steps.check_tests.outputs.has_tests }}

strategy:
matrix:
php: ['7.4']
moodle-branch: ['MOODLE_311_STABLE']
moodle-branch: ['MOODLE_400_STABLE']
database: ['pgsql']

steps:
- name: Start PostgreSQL
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:9.6
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:10

- name: Check out repository code
uses: actions/checkout@v2
with:
path: plugin

- name: Check for test folder
id: check_tests
run: |
echo "::set-output name=has_tests::${{ hashFiles('plugin/tests') != '' }}"
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
Expand Down Expand Up @@ -101,22 +109,23 @@ jobs:
test:
runs-on: ubuntu-latest
needs: static
if: ${{ needs.static.outputs.has_tests == 'true' }}

strategy:
fail-fast: false
matrix:
php: ['7.3', '7.4']
moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE']
php: ['7.4']
moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE', 'MOODLE_400_STABLE']
database: ['mariadb', 'pgsql']

steps:
- name: Start MariaDB
if: matrix.database == 'mariadb'
run: docker run -p 3306:3306 -e MYSQL_USER=root -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mariadb:10.5
run: docker run -p 3306:3306 -e MYSQL_USER=root -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mariadb:10

- name: Start PostgreSQL
if: matrix.database == 'pgsql'
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:9.6
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:10

- name: Check out repository code
uses: actions/checkout@v2
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/moodle-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Whenever a new tag starting with "v" is pushed, add the tagged version
# to the Moodle Plugins directory at https://moodle.org/plugins
#
# revision: 2021070201
# Changed to be released on Github release with the release notes.
#
name: Releasing in the Plugins directory

on:
release:
types: [published]

defaults:
run:
shell: bash

jobs:
release-at-moodle-org:
runs-on: ubuntu-latest
env:
PLUGIN: block_qrcode
CURL: curl -s
ENDPOINT: https://moodle.org/webservice/rest/server.php
TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }}
FUNCTION: local_plugins_add_version

steps:
- name: Call the service function
id: add-version
run: |
TAGNAME="${{ github.event.release.tag_name }}"
BODY="${{ github.event.release.body }}"
ZIPURL="${{ github.event.release.zipball_url }}"
RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \
--data-urlencode "wsfunction=${FUNCTION}" \
--data-urlencode "moodlewsrestformat=json" \
--data-urlencode "frankenstyle=${PLUGIN}" \
--data-urlencode "zipurl=${ZIPURL}" \
--data-urlencode "vcssystem=git" \
--data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
--data-urlencode "vcstag=${TAGNAME}" \
--data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \
--data-urlencode "altdownloadurl=${ZIPURL}" \
--data-urlencode "releasenotes=${BODY}" \
--data-urlencode "releaseformat=4")
echo "::set-output name=response::${RESPONSE}"
- name: Evaluate the response
id: evaluate-response
env:
RESPONSE: ${{ steps.add-version.outputs.response }}
run: |
jq <<< ${RESPONSE}
jq --exit-status ".id" <<< ${RESPONSE} > /dev/null
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@

$plugin->component = 'block_qrcode'; // Full name of the plugin.
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'v3.10-r1';
$plugin->version = 2020111700; // The current plugin version (Date: YYYMMDDXX).
$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->release = 'v4.0-r1';
$plugin->version = 2022040400; // The current plugin version (Date: YYYMMDDXX).
$plugin->requires = 2020061500; // Requires Moodle 3.9+.

0 comments on commit 1187a59

Please sign in to comment.