-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (132 loc) · 5.04 KB
/
Copy pathrelease.yml
File metadata and controls
144 lines (132 loc) · 5.04 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Release FPA
on:
workflow_dispatch:
inputs:
version:
description: Release version (e.g. 1.0.4). Leave empty to use conf.yml.
required: false
default: ""
environment:
description: Mythic Marketplace environment
type: choice
options:
- production
- dev
default: production
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate secrets
shell: bash
env:
HAS_PRODUCT_ID: ${{ secrets.MYTHIC_PRODUCT_ID != '' }}
HAS_RELEASE_TOKEN: ${{ secrets.MYTHIC_RELEASE_TOKEN != '' }}
run: |
missing=0
if [ "${HAS_PRODUCT_ID}" != "true" ]; then
echo "::error::Missing repository secret MYTHIC_PRODUCT_ID"
missing=1
fi
if [ "${HAS_RELEASE_TOKEN}" != "true" ]; then
echo "::error::Missing repository secret MYTHIC_RELEASE_TOKEN"
missing=1
fi
if [ "${missing}" -ne 0 ]; then
exit 1
fi
- name: Resolve version
id: version
shell: bash
run: |
if [ -n "${{ inputs.version }}" ]; then
ver="${{ inputs.version }}"
else
ver="$(grep -E '^\s*version:' conf.yml | head -1 | sed -E 's/^[[:space:]]*version:[[:space:]]*//; s/["'\'']//g')"
fi
if [ -z "${ver}" ]; then
echo "::error::Could not resolve release version. Set the version input or add version to conf.yml."
exit 1
fi
echo "version=${ver}" >> "$GITHUB_OUTPUT"
- name: Sync conf.yml version
id: sync_conf
shell: bash
run: |
ver="${{ steps.version.outputs.version }}"
current="$(grep -E '^\s*version:' conf.yml | head -1 | sed -E 's/^[[:space:]]*version:[[:space:]]*//; s/["'\'']//g')"
if [ "${current}" = "${ver}" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "conf.yml already at ${ver}"
exit 0
fi
sed -i -E "s/^([[:space:]]*version:[[:space:]]*).*/\1${ver}/" conf.yml
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Updated conf.yml: ${current} -> ${ver}"
- name: Build .fpa
id: build
uses: MythicalLTD/.github/actions/build-fpa@v1
with:
skip_checkout: "true"
build_frontend: "true"
package_manager: "auto"
artifact_name: ""
- name: Publish to Mythic Marketplace
id: publish
uses: MythicalLTD/.github/actions/publish-release@v1
with:
product_id: ${{ secrets.MYTHIC_PRODUCT_ID }}
environment: ${{ inputs.environment }}
version: ${{ steps.version.outputs.version }}
changelog: Updated to latest plugin version
file_path: ${{ steps.build.outputs.fpa_file }}
title: "${{ steps.build.outputs.plugin_identifier }} ${{ steps.version.outputs.version }}"
release_token: ${{ secrets.MYTHIC_RELEASE_TOKEN }}
- name: Create GitHub Release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
ver="${{ steps.version.outputs.version }}"
tag="v${ver}"
fpa="${{ steps.build.outputs.fpa_file }}"
if gh release view "${tag}" >/dev/null 2>&1; then
gh release upload "${tag}" "${fpa}" --clobber
gh release edit "${tag}" --notes "Updated to latest plugin version"
else
gh release create "${tag}" "${fpa}" --title "${tag}" --notes "Updated to latest plugin version"
fi
- name: Commit version bump
if: steps.sync_conf.outputs.changed == 'true'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if git diff --quiet -- conf.yml; then
echo "conf.yml already matches remote — nothing to commit"
exit 0
fi
git add conf.yml
git commit -m "chore: bump version to ${{ steps.version.outputs.version }}"
git push
- name: Release summary
if: success()
shell: bash
run: |
{
echo "### Release published"
echo "| Plugin | \`${{ steps.build.outputs.plugin_identifier }}\` |"
echo "| Version | \`${{ steps.version.outputs.version }}\` |"
echo "| FPA | \`${{ steps.build.outputs.fpa_filename }}\` |"
echo "| Environment | \`${{ inputs.environment }}\` |"
echo "| Marketplace release | \`${{ steps.publish.outputs.release_url }}\` |"
echo "| GitHub release | [\`v${{ steps.version.outputs.version }}\`](${{ github.server_url }}/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }}) |"
} >> "$GITHUB_STEP_SUMMARY"