Generate Github Release Zip #24
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |