-
Notifications
You must be signed in to change notification settings - Fork 2
180 lines (162 loc) · 6.72 KB
/
GenerateReleaseZip.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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Generate Github Release Zip
env:
# Change this to point to your solution, or the folder in which your solution
# can be found.
SLN_PATH: Source/
# Change this to what you want your folder name to be in people's Mods/
# folder. It should be unique to your mod.
MOD_NAME: MeleeAnimation
# These two environment variables control whether all releases created by the
# release job are drafts or prereleases.
RELEASE_DRAFT: false
RELEASE_PRERELEASE: false
on:
push:
tags:
# This will only run the release workflow when it's tagged with a version
# tag.
- 'v*'
jobs:
build:
name: Build on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
# You only need one platform for building the release since the DLLs are
# cross-platform using mono. I chose Ubuntu because it ran the fastest
# for the build steps.
operating-system: [ubuntu-latest]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Build Mod 1.4
run: dotnet build ${{ env.SLN_PATH }} --configuration v1.4
# I don't know how well testing will work without Rimworld actually installed.
# But if you have unit tests configured to work with dotnet, you may be able
# to uncomment this and add a testing step.
# - name: Test Mod
# run: dotnet test ${{ env.SLN_PATH }} --no-restore --verbosity normal
# There is no `zip` command on windows so you need to use tar.
# - name: Zip-up Mod
# run: tar --exclude="*." -zcvf dist.tar.gz About/ Assemblies/ Defs/ Languages/ Patches/ RimCI/ Sounds/ Textures/
# To modify this with your own directory structure, just change the paths to
# whatever you want. It will not upload any empty directories, those with only
# hidden files will also be excluded.
- name: Upload Mod Artifacts
uses: actions/upload-artifact@v3
with:
name: build
retention-days: 7
path: |
1.4/
About/
Animations/
Bundles/
WeaponTweakData/
Defs/
Patches/
Languages/
Patch_AlienRaces/
Patch_FacialAnimation/
Patch_Lightsabers/
Patch_CAI5000/
Patch_CombatExtended/
Sounds/
Textures/
loadfolders.xml
!**/.*
# This final path is to exclude hidden files such as .gitkeep and .DS_STORE.
# I would recommend keeping it, but I don't think it will break anything if
# you remove or modify it.
package:
name: Package
needs: build
runs-on: ubuntu-latest
steps:
- name: Set Environment Variables
# This is a special syntax for GitHub Actions that sets an environment
# variable. See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: echo "MOD_PATH=$HOME/$MOD_NAME" >> $GITHUB_ENV
# run: echo "::set-env name=MOD_PATH::$HOME/$MOD_NAME"
- name: Create Mod Folder
run: mkdir -p ${{ env.MOD_PATH }}
- name: Download Mod Artifacts from Build Step
uses: actions/download-artifact@v3
with:
name: build
path: ${{ env.MOD_PATH }}
# If you have any other Rimworld folders that didn't get scooped up in the
# artifacts, add them here. It may be neccessary to change this for v1.1 mods.
- name: Create Mod Folders
run: |
mkdir -p ${{ env.MOD_PATH }}/1.4/
mkdir -p ${{ env.MOD_PATH }}/About/
mkdir -p ${{ env.MOD_PATH }}/Animations/
mkdir -p ${{ env.MOD_PATH }}/Bundles/
mkdir -p ${{ env.MOD_PATH }}/WeaponTweakData/
mkdir -p ${{ env.MOD_PATH }}/Defs/
mkdir -p ${{ env.MOD_PATH }}/Patches/
mkdir -p ${{ env.MOD_PATH }}/Languages/
mkdir -p ${{ env.MOD_PATH }}/Patch_AlienRaces/
mkdir -p ${{ env.MOD_PATH }}/Patch_FacialAnimation/
mkdir -p ${{ env.MOD_PATH }}/Patch_Lightsabers/
mkdir -p ${{ env.MOD_PATH }}/Patch_CAI5000/
mkdir -p ${{ env.MOD_PATH }}/Patch_CombatExtended/
mkdir -p ${{ env.MOD_PATH }}/Sounds/
mkdir -p ${{ env.MOD_PATH }}/Textures/
- name: Zip Mod
run: |
cd $HOME
zip -r ./${{ env.MOD_NAME }}.zip ./${{ env.MOD_NAME }}/*
- name: Upload Mod Zip Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.MOD_NAME }}
path: ${{ env.MOD_PATH }}.zip
retention-days: 5
release:
name: Release
needs: package
runs-on: ubuntu-latest
steps:
- name: Get the Version
id: get_version
# This is a special syntax for GitHub Actions that sets an output
# variable. See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
# run: echo ::set-output name=VERSION::$(echo ${{ github.ref }} | cut -d / -f 3)
run: echo "VERSION=$(echo ${{ github.ref }} | cut -d / -f 3)" >> $GITHUB_OUTPUT
- name: Set Environment Variables
# This is a special syntax for GitHub Actions that sets an environment
# variable. See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
# run: echo "::set-env name=MOD_RELEASE::$MOD_NAME-${{ steps.get_version.outputs.VERSION }}"
run: echo "MOD_RELEASE=$MOD_NAME-${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
- name: Download Mod Artifacts from Build Step
id: download_zip
uses: actions/download-artifact@v3
with:
name: ${{ env.MOD_NAME }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.CI_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ env.MOD_RELEASE }}
# These can be configured at the top of the workflow.
draft: ${{ env.RELEASE_DRAFT }}
prerelease: ${{ env.RELEASE_PRERELEASE }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.CI_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ steps.download_zip.outputs.download-path }}/${{ env.MOD_NAME }}.zip
asset_name: ${{ env.MOD_RELEASE }}.zip
asset_content_type: application/zip