Skip to content

Publish Release

Publish Release #58

Workflow file for this run

# Creates a release using compose.py from https://github.com/CleverRaven/Cataclysm-DDA
#
# This action is runs at 20:00 UTC Sunday
name: Publish Release
concurrency: release
on:
schedule:
- cron: '0 20 * * sun'
workflow_dispatch:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
timestamp: ${{ steps.get-timestamp.outputs.time }}
release_already_exists: ${{ steps.tag_check.outputs.exists }}
steps:
- name: Get build timestamp
id: get-timestamp
uses: nanzm/[email protected]
with:
format: 'YYYY-MM-DD'
- name: Generate environmental variables
id: generate_env_vars
run: |
echo "TAG-NAME=${{ steps.get-timestamp.outputs.time }}" >> $GITHUB_OUTPUT
echo "RELEASE-TITLE=Cuteclysm Release ${{ steps.get-timestamp.outputs.time }}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if there is existing git tag
id: tag_check
uses: mukunku/[email protected]
with:
tag: ${{ steps.generate_env_vars.outputs.TAG-NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Previous tag
id: previous_tag
uses: WyriHaximus/github-action-get-previous-tag@v1
- name: Abort if there are no changes
run: |
# exit 1 if there are no changes, exit 0 if there are changes
git diff ${{ steps.previous_tag.outputs.tag }} | grep -q ""
- name: Push tag
id: tag_version
uses: mathieudutour/[email protected]
if: ${{ steps.tag_check.outputs.exists == 'false' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.generate_env_vars.outputs.TAG-NAME }}
tag_prefix: ""
- name: "Generate release notes"
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/repos/${{github.repository}}/releases/generate-notes \
-f tag_name='${{ steps.generate_env_vars.outputs.TAG-NAME }}' \
-f target_commitish='master' \
-q .body > CHANGELOG.md
- name: Create release
id: create_release
uses: actions/create-release@main
if: ${{ steps.tag_check.outputs.exists == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.generate_env_vars.outputs.TAG-NAME }}
release_name: ${{ steps.generate_env_vars.outputs.RELEASE-TITLE }}
body_path: ./CHANGELOG.md
draft: false
prerelease: false
build:
needs: release
if: ${{ needs.release.outputs.release_already_exists == 'false' }}
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: musl python3 python3-pip libvips42
# re-installing libvips; caching it won't set it up the way we need it
# still cache it because we'll make it work somehow
- run: sudo apt-get install libvips42
- run: pip3 install pyvips
- uses: actions/checkout@v3
- name: Build
id: build
run: |
wget -q https://raw.githubusercontent.com/CleverRaven/Cataclysm-DDA/master/tools/gfx_tools/compose.py \
|| echo "Error: Failed to get compose.py"
mkdir build
python3 compose.py --use-all --feedback CONCISE --loglevel INFO . build
release_name=Cuteclysm
mkdir "$release_name"
cp -r build/* "$release_name"
cp ./tileset.txt "$release_name"
cp ./fallback.png "$release_name"
[ -f "./layering.json" ] && mv "./layering.json" $release_name
zip -r $release_name.zip $release_name
echo "RELEASE-NAME=$release_name" >> $GITHUB_OUTPUT
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ steps.build.outputs.RELEASE-NAME }}.zip
asset_name: ${{ steps.build.outputs.RELEASE-NAME }}.zip
asset_content_type: application/zip