-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (60 loc) · 2.75 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Moodle Plugin CI
on:
release:
types: [created]
jobs:
release:
runs-on: ubuntu-22.04
env:
PLUGIN_NAME: 'local_logging'
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