Skip to content

v3.0.1

v3.0.1 #19

Workflow file for this run

name: Publish package
on:
release:
types: [published] # run when a new release is published
tags:
- 'v*' # Trigger only if the tag matches eg. v1.0.0
workflow_run:
workflows: ["build"] # run if build.yml is successfully completed
types:
- completed
env:
name: ChebsMercenaries
jsonf: manifest.json
dlpath: https://github.com/jpw1991/chebs-mercenaries/releases/download
dependencies: "[email protected]" # dependencies separated by spaces
categories: "Mods" # categories separated by spaces
namespace: ChebGonaz
jobs:
verify-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check tag
run: |
# the tags check above doesn't seem to work properly, so a more rigorous check here
if [ "${{ github.event_name }}" == "release" ]; then
echo "This workflow was triggered by a release."
release_tag="${{ github.event.release.tag_name }}"
# Check if the tag matches semantic versioning pattern
if ! [[ $release_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+)?$ ]]; then
echo "Error: Release tag ($release_tag) does not match semantic versioning pattern."
exit 1
fi
exit 0
elif [ "${{ github.event_name }}" == "workflow_run" ]; then
echo "This workflow was triggered by a workflow run."
exit 0
else
echo "This workflow was triggered by an unknown event: ${{ github.event_name }}"
exit 1
fi
publish:
needs: verify-tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Read manifest
run: |
version="$(jq -r '.version_number' ${{env.name}}/Package/${{env.jsonf}})"
description="$(jq -r '.description' ${{env.name}}/Package/${{env.jsonf}})"
echo "VERSION=${version}" >> $GITHUB_ENV
echo "DESCRIPTION=${description}" >> $GITHUB_ENV
- run: wget ${{env.dlpath}}/v${{env.VERSION}}/${{env.name}}.${{env.VERSION}}.zip
- name: Upload Thunderstore Package
uses: GreenTF/upload-thunderstore-package@v4
with:
community: valheim
namespace: ${{env.namespace}}
name: ${{env.name}}
version: ${{env.VERSION}}
description: ${{env.DESCRIPTION}}
token: ${{secrets.TS_KEY}}
deps: ${{env.dependencies}}
categories: ${{env.categories}}
file: ${{env.name}}.${{env.VERSION}}.zip