1 |
efrain |
1 |
#
|
|
|
2 |
# Whenever a new tag starting with "v" is pushed, add the tagged version
|
|
|
3 |
# to the Moodle Plugins directory at https://moodle.org/plugins
|
|
|
4 |
#
|
|
|
5 |
# revision: 2021070201
|
|
|
6 |
#
|
|
|
7 |
name: Releasing in the Plugins directory
|
|
|
8 |
|
|
|
9 |
on:
|
|
|
10 |
push:
|
|
|
11 |
tags:
|
|
|
12 |
- v*
|
|
|
13 |
|
|
|
14 |
workflow_dispatch:
|
|
|
15 |
inputs:
|
|
|
16 |
tag:
|
|
|
17 |
description: 'Tag to be released'
|
|
|
18 |
required: true
|
|
|
19 |
|
|
|
20 |
defaults:
|
|
|
21 |
run:
|
|
|
22 |
shell: bash
|
|
|
23 |
|
|
|
24 |
jobs:
|
|
|
25 |
release-at-moodle-org:
|
|
|
26 |
runs-on: ubuntu-latest
|
|
|
27 |
env:
|
|
|
28 |
PLUGIN: block_people
|
|
|
29 |
CURL: curl -s
|
|
|
30 |
ENDPOINT: https://moodle.org/webservice/rest/server.php
|
|
|
31 |
TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }}
|
|
|
32 |
FUNCTION: local_plugins_add_version
|
|
|
33 |
|
|
|
34 |
steps:
|
|
|
35 |
- name: Call the service function
|
|
|
36 |
id: add-version
|
|
|
37 |
run: |
|
|
|
38 |
if [[ ! -z "${{ github.event.inputs.tag }}" ]]; then
|
|
|
39 |
TAGNAME="${{ github.event.inputs.tag }}"
|
|
|
40 |
elif [[ $GITHUB_REF = refs/tags/* ]]; then
|
|
|
41 |
TAGNAME="${GITHUB_REF##*/}"
|
|
|
42 |
fi
|
|
|
43 |
if [[ -z "${TAGNAME}" ]]; then
|
|
|
44 |
echo "No tag name has been provided!"
|
|
|
45 |
exit 1
|
|
|
46 |
fi
|
|
|
47 |
ZIPURL="https://api.github.com/repos/${{ github.repository }}/zipball/${TAGNAME}"
|
|
|
48 |
RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \
|
|
|
49 |
--data-urlencode "wsfunction=${FUNCTION}" \
|
|
|
50 |
--data-urlencode "moodlewsrestformat=json" \
|
|
|
51 |
--data-urlencode "frankenstyle=${PLUGIN}" \
|
|
|
52 |
--data-urlencode "zipurl=${ZIPURL}" \
|
|
|
53 |
--data-urlencode "vcssystem=git" \
|
|
|
54 |
--data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
|
|
|
55 |
--data-urlencode "vcstag=${TAGNAME}" \
|
|
|
56 |
--data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \
|
|
|
57 |
--data-urlencode "altdownloadurl=${ZIPURL}")
|
|
|
58 |
echo "response=${RESPONSE}" >> $GITHUB_OUTPUT
|
|
|
59 |
|
|
|
60 |
- name: Evaluate the response
|
|
|
61 |
id: evaluate-response
|
|
|
62 |
env:
|
|
|
63 |
RESPONSE: ${{ steps.add-version.outputs.response }}
|
|
|
64 |
run: |
|
|
|
65 |
jq <<< ${RESPONSE}
|
|
|
66 |
jq --exit-status ".id" <<< ${RESPONSE} > /dev/null
|