-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (59 loc) · 2.08 KB
/
publish-mod.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
# This workflow publishes a Diggles mod of a project on Github
name: Publish Github
on:
workflow_call:
inputs:
mod-title:
description: 'The name that should be added to the title of the Release on Github'
required: true
type: string
mod-name:
description: 'The name that should be used for filenames'
required: true
type: string
secrets:
github-token:
description: 'Github token'
required: true
jobs:
publish:
name: Publish Github
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
packages: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Version
id: get_version
uses: actions/github-script@v7
with:
github-token: ${{ secrets.github-token }}
result-encoding: string
script: |
return '${{ github.ref }}'.replace('refs/tags/', '');
- name: Get Changelog
id: get_changelog
run: |
content=`cat ./CHANGELOG.md | sed '0,/^## \[${{ steps.get_version.outputs.result }}\]/d' | sed '/^## \[/,$d'`
delimiter="$(openssl rand -hex 8)"
echo "result<<$delimiter" >> $GITHUB_OUTPUT
echo "$content" >> $GITHUB_OUTPUT
echo "$delimiter" >> $GITHUB_OUTPUT
- name: Create ZIP file
run: |
mkdir ${{ inputs.mod-name }}
rsync -av --exclude=".*" --exclude="${{ inputs.mod-name }}/" . ${{ inputs.mod-name }}
zip -r -q ${{ inputs.mod-name }}-${{ steps.get_version.outputs.result }}.zip ${{ inputs.mod-name }}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.result }}
name: ${{ inputs.mod-title }} ${{ steps.get_version.outputs.result }}
body: ${{ steps.get_changelog.outputs.result }}
draft: false
prerelease: false
files: ${{ inputs.mod-name }}-${{ steps.get_version.outputs.result }}.zip
token: ${{ secrets.github-token }}