v20.1.2.0 #16
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: "Attach Release Artifacts" | |
# Controls when the action will run. | |
on: | |
release: | |
types: [published] | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
attach-release-artifacts: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Get Branch | |
shell: bash | |
run: | | |
releaseBranch=$(git branch -a --contains ${GITHUB_SHA} | head -n 2 | tail -n 1 | sed -e "s/\s*//" | sed -e "s/remotes\/origin\///") | |
echo "Found branch ${releaseBranch}" | |
echo "tagged_branch=${releaseBranch}" >> $GITHUB_ENV | |
- name: Download required assemblies | |
id: download-assemblies | |
shell: bash | |
env: | |
KSP_ZIP_PASSWORD: ${{ secrets.KSP_ZIP_PASSWORD }} | |
run: | | |
curl https://ksp-ro.s3-us-west-2.amazonaws.com/KSPAssemblies-1.12.zip --output /tmp/bins.zip | |
KSP_DLL_PATH="/opt/ksp/assembly" | |
echo "::set-output name=ksp-dll-path::${KSP_DLL_PATH}" | |
mkdir -p "${KSP_DLL_PATH}" | |
unzip -P "${KSP_ZIP_PASSWORD}" '/tmp/bins.zip' -d "${KSP_DLL_PATH}" | |
rm '/tmp/bins.zip' | |
- name: Build mod solution | |
env: | |
TAG_STRING: ${{ github.event.release.tag_name }} | |
run: | | |
VFULL="$(echo $TAG_STRING | sed -e s/v//)" | |
VMAJOR="$(echo $VFULL | cut -f 1 -d '.')" | |
VMINOR="$(echo $VFULL | cut -f 2 -d '.')" | |
VPATCH="$(echo $VFULL | cut -f 3 -d '.')" | |
VBUILD="$(echo $VFULL | cut -f 4 -d '.')" | |
echo "Version string: $TAG_STRING" | |
echo "Version is $VMAJOR dot $VMINOR dot $VPATCH dot $VBUILD" | |
sed \ | |
-e "s/CIBUILD_disabled/CIBUILD/" \ | |
-e "s/@MAJOR@/$VMAJOR/" \ | |
-e "s/@MINOR@/$VMINOR/" \ | |
-e "s/@PATCH/$VPATCH/" \ | |
-e "s/@BUILD@/$VBUILD/" \ | |
-i ${GITHUB_WORKSPACE}/Source/Properties/AssemblyInfo.cs | |
grep CIBUILD ${GITHUB_WORKSPACE}/Source/Properties/AssemblyInfo.cs | |
grep AssemblyVersion ${GITHUB_WORKSPACE}/Source/Properties/AssemblyInfo.cs | |
grep AssemblyFileVersion ${GITHUB_WORKSPACE}/Source/Properties/AssemblyInfo.cs | |
rm -f ${GITHUB_WORKSPACE}/GameData/RealSolarSystem/Plugins/*.dll | |
msbuild /p:Configuration=Release /p:ReferencePath="${{ steps.download-assemblies.outputs.ksp-dll-path }}" ${GITHUB_WORKSPACE}/Source/RealSolarSystem.sln | |
cp -v ${GITHUB_WORKSPACE}/Source/obj/Release/RealSolarSystem.dll ${GITHUB_WORKSPACE}/GameData/RealSolarSystem/Plugins/RealSolarSystem.dll | |
- name: Remove excess DLLs | |
uses: KSP-RO/BuildTools/remove-excess-dlls@master | |
with: | |
path: ${GITHUB_WORKSPACE}/GameData/ | |
- name: Setup python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.0 | |
- name: Make metadata | |
run: | | |
python ${GITHUB_WORKSPACE}/makeMeta.py ${{ github.event.release.tag_name }} | |
- name: Assemble release | |
id: assemble-release | |
run: | | |
RELEASE_DIR="${RUNNER_TEMP}/release" | |
echo "Release dir: ${RELEASE_DIR}" | |
echo "Release zip: ${RELEASE_DIR}/RealSolarSystem_${{ github.event.release.tag_name }}.zip" | |
mkdir -v "${RELEASE_DIR}" | |
echo "::set-output name=release-dir::${RELEASE_DIR}" | |
cp -v -R "${GITHUB_WORKSPACE}/GameData" "${RELEASE_DIR}" | |
cp -v -R "${GITHUB_WORKSPACE}/RealSolarSystem.version" "${RELEASE_DIR}/GameData/RealSolarSystem/RealSolarSystem.version" | |
cd ${RELEASE_DIR} | |
zip -r RealSolarSystem_${{ github.event.release.tag_name }}.zip GameData | |
- name: Upload package to release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ${{ steps.assemble-release.outputs.release-dir }}/RealSolarSystem_${{ github.event.release.tag_name }}.zip | |
asset_name: RealSolarSystem_${{ github.event.release.tag_name }}.zip | |
asset_content_type: application/zip | |
- name: Setup git config | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
- name: Commit new version file | |
shell: bash | |
env: | |
TAG_STRING: ${{ github.event.release.tag_name }} | |
run: | | |
RELEASEBRANCH=${{ env.tagged_branch }} | |
echo "Checking out branch ${RELEASEBRANCH}" | |
git checkout $RELEASEBRANCH | |
git reset --hard origin/$RELEASEBRANCH | |
cp -v "${GITHUB_WORKSPACE}/RealSolarSystem.version" "${GITHUB_WORKSPACE}/GameData/RealSolarSystem/RealSolarSystem.version" | |
git add "${GITHUB_WORKSPACE}/GameData/RealSolarSystem/RealSolarSystem.version" | |
git commit -m "Update version to $TAG_STRING" | |
git push origin $RELEASEBRANCH |