-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithub_workflows_build-release.yml
More file actions
164 lines (143 loc) · 5.58 KB
/
Copy pathgithub_workflows_build-release.yml
File metadata and controls
164 lines (143 loc) · 5.58 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Publish Release
permissions:
contents: write
on:
workflow_dispatch:
inputs:
release-type:
description: 'Release Type'
default: 'feature'
required: false
type: choice
options:
- 'major'
- 'feature'
- 'patch'
publish:
description: 'Publish on Workshop'
required: false
default: 'true'
type: choice
options:
- 'true'
- 'false'
workshop-id:
description: 'Workshop Identifier'
required: false
default: '3371693463'
type: string
jobs:
release:
name: "Create GitHub Release"
runs-on: ubuntu-latest
outputs:
version: ${{ steps.increment-version.outputs.next-version }}
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Checkout Tags
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch --prune --unshallow --tags
# Get the latest tag from git
# Tag is used as the last version
- name: Get Version
id: project
run: |
echo "last-version=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_OUTPUT
- name: Increment Version
id: increment-version
uses: christian-draeger/increment-semantic-version@1.2.1
with:
current-version: ${{ steps.project.outputs.last-version }}
version-fragment: ${{ inputs.release-type }}
# Collect commits since the last tag
# Format them as a Markdown list and put them into the summary
# Report: Commit list
- name: Collect Changes
id: commits
run: |
{
echo 'markdown<<EOF'
echo "$(git log ${{ steps.project.outputs.last-version }}..HEAD --no-merges --pretty=format:' - %s')"
echo EOF
} >> "$GITHUB_OUTPUT"
echo "# Commits" >> $GITHUB_STEP_SUMMARY
echo "$(git log ${{ steps.project.outputs.last-version }}..HEAD --no-merges --pretty=format:' - %s')" >> $GITHUB_STEP_SUMMARY
# Replace the old version in metadata.json with the new one
# Commit the metadata.json
# Report: Last and Next version
- name: Update Version
run: |
sed -i 's/"version" : "${{ steps.project.outputs.last-version }}"/"version" : "${{ steps.increment-version.outputs.next-version }}"/g' mod/.metadata/metadata.json
git commit -am "Updated version to ${{ steps.increment-version.outputs.next-version }}"
echo "# Versions" >> $GITHUB_STEP_SUMMARY
echo "Last Version: **${{ steps.project.outputs.last-version }}**" >> $GITHUB_STEP_SUMMARY
echo "Next Version: **${{ steps.increment-version.outputs.next-version }}**" >> $GITHUB_STEP_SUMMARY
- name: Push Version
run: |
git push origin
# Package mod folder into a zip file
- name: Create Release Artifact
run: |
rm -f mod/vic3-tiger.conf
(cd mod; zip -r release-${{ steps.increment-version.outputs.next-version }}.zip .)
# Attach mod package to the workflow run
- name: Upload Release Artifact
uses: actions/upload-artifact@v4
with:
name: Release
path: mod/release-${{ steps.increment-version.outputs.next-version }}.zip
# Create a GitHub release
# Includes the list of commits
# Includes the mod package
- name: Publish GitHub Release
id: create_release
uses: softprops/action-gh-release@v2.2.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false
files: mod/release-${{ steps.increment-version.outputs.next-version }}.zip
tag_name: ${{ steps.increment-version.outputs.next-version }}
name: ${{ steps.increment-version.outputs.next-version }}
body: |
Released a new version of the **States Merging** mod.
### Commits:
${{ steps.commits.outputs.markdown }}
# Delete mod package so it is not published to steam
- name: Clean Release Artifact
run: |
rm -f mod/release-${{ steps.increment-version.outputs.next-version }}.zip
publish:
if: ${{ inputs.publish == 'true' }}
name: "Publish to Workshop"
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
with:
ref: "${{ needs.release.outputs.version }}"
# Create mod metadata for the steam release
# Uses STEAM_PAGE.bbcode to update steam description
# Report: Generated metadata
- name: Create Workshop Metadata
id: metadata
shell: bash
run: |
(cd script; ./create-release-vdf.sh mod documentation/STEAM_PAGE.bbcode "${{ inputs.workshop-id }}")
echo "vdf=$(realpath workshop.vdf)" >> "$GITHUB_OUTPUT"
echo "# Workflow Metadata" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "$(cat < workshop.vdf)" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Setup SteamCMD
uses: CyberAndrii/setup-steamcmd@v1
# Publish to steam workshop
# Uses generated metadata and configured workshop user
- name: Publish to Workshop
shell: bash
run: |
steamcmd +login ${{ secrets.WORKSHOP_USERNAME }} ${{ secrets.WORKSHOP_PASSWORD }} +workshop_build_item ${{ steps.metadata.outputs.vdf }} +quit