-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
112 lines (98 loc) · 3.21 KB
/
action.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: 'Update'
inputs:
version:
required: true
download_url:
required: false
download_path:
required: false
changelog:
required: false
changelog_extract:
required: false
strip_archive_folder:
description: "Remove the parent folder of the downloaded archive (defaults to true)"
default: 'true'
required: false
outputs:
updated:
description: Whether the update was needed and completed or not
value: ${{ steps.completed-job.outputs.updated }}
version:
description: The version
value: ${{ steps.completed-job.outputs.version }}
runs:
using: 'composite'
steps:
- name: Fetch tags
shell: bash
run: git fetch --prune --unshallow --tags
- name: Check if latest version exists
shell: bash
run: |
if git show-ref --tags --verify --quiet "refs/tags/${{ inputs.version }}"; then
echo "RUN_BUILD=false" >> "$GITHUB_ENV"
else
echo "RUN_BUILD=true" >> "$GITHUB_ENV"
fi
- name: Install requirements
if: env.RUN_BUILD == 'true'
shell: bash
run: sudo apt-get install -y libarchive-tools
- name: Download and extract the package
if: env.RUN_BUILD == 'true'
shell: bash
run: |
git rm -rf .
git clean -fxd
if [ ! -z "${{ inputs.download_url }}" ]; then
curl -L '${{ inputs.download_url }}' > package.zip
elif [ ! -z "${{ inputs.download_path }}" ]; then
mv "${{ inputs.download_path }}" package.zip
else
echo "Missing package/download_url input"
exit 1
fi
bsdtar --strip-components=${{ inputs.strip_archive_folder == 'true' && 1 || 0 }} -xvf package.zip
rm package.zip
git reset HEAD composer.json .github
git checkout -- composer.json .github
git add .
- name: Create commit message
shell: bash
run: |
{
echo "v${{ inputs.version }}"
echo
} >| /tmp/commit-message
- name: Extract changelog
if: ${{ env.RUN_BUILD == 'true' && inputs.changelog_extract != '' && inputs.changelog == '' }}
shell: bash
run: |
${{ inputs.changelog_extract }} >> /tmp/commit-message
- name: Retrieve changelog
if: ${{ env.RUN_BUILD == 'true' && inputs.changelog != '' }}
shell: bash
run: |
echo "${{ inputs.changelog }}" >> /tmp/commit-message
- name: Commit the changes and push them
if: ${{ env.RUN_BUILD == 'true' }}
shell: bash
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit --file /tmp/commit-message
git tag --annotate ${{ inputs.version }} --file /tmp/commit-message
git push
git push origin tag ${{ inputs.version }}
# Release workflow not triggered from other workflows
- name: Publish release
if: ${{ env.RUN_BUILD == 'true' }}
uses: ghalactic/github-release-from-tag@v5
- name: Set output status
id: completed-job
shell: bash
run: |
echo "updated=${{ env.RUN_BUILD }}" >> $GITHUB_OUTPUT
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT