-
Notifications
You must be signed in to change notification settings - Fork 2
151 lines (133 loc) · 5.3 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
name: Generate Github Release Zip
env:
# 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
MOD_CONTENTS: |
About/
Animations/
Bundles/
WeaponTweakData/
Defs/
Patches/
Languages/
Patch_AlienRaces/
Patch_FacialAnimation/
Patch_Lightsabers/
Patch_CAI5000/
Patch_CombatExtended/
Sounds/
Textures/
loadfolders.xml
on:
push:
tags:
# This will only run the release workflow when it's tagged with a version
# tag.
- 'v*'
jobs:
build:
name: Build for RW v${{ matrix.rimworld-version }}
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]
rimworld-version: [1.4, 1.5] # Add Rimworld version here!
steps:
- name: Checkout Repository
uses: actions/[email protected]
- name: Setup Dotnet
uses: actions/[email protected]
with:
dotnet-version: 8.0.x
- name: Build Mod (RW ${{ matrix.rimworld-version }})
run: dotnet build Source/${{ matrix.rimworld-version }} --configuration Release
# 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 (RW ${{ matrix.rimworld-version }})
uses: actions/[email protected]
with:
name: build-${{ matrix.rimworld-version }}
retention-days: 1
path: |
${{ matrix.rimworld-version }}/
${{ env.MOD_CONTENTS }}
!**/.*
# 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
- name: Create Mod Folder
run: mkdir -p ${{ env.MOD_PATH }}
- name: Download Mod Artifacts from Build Step
uses: actions/[email protected]
with:
# Note that 'name' is not specified, this will cause all artifacts from this run to be downloaded.
merge-multiple: true # Important, this merges the different rimworld version outputs
path: ${{ env.MOD_PATH }}
- name: Zip Mod
run: |
cd $HOME
zip -r ./${{ env.MOD_NAME }}.zip ./${{ env.MOD_NAME }}/*
- name: Upload Mod Zip Artifact
uses: actions/[email protected]
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 "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 "MOD_RELEASE=$MOD_NAME-${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
- name: Download Mod Artifacts from Build Step
id: download_zip
uses: actions/[email protected]
with:
name: ${{ env.MOD_NAME }}
- name: Create Release
id: create_release
uses: actions/[email protected]
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