Skip to content

MCP: AI assistants can request crafts and set stock rules (#201) #105

MCP: AI assistants can request crafts and set stock rules (#201)

MCP: AI assistants can request crafts and set stock rules (#201) #105

Workflow file for this run

name: Publish image
# Pushes the server image to ghcr.io/<owner>/<repo> when a version tag
# (e.g. v1.2.0) is pushed. Tags produced: 1.2.0, 1.2, latest.
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
jobs:
# The whole of ci.yml, so a tag on a commit that fails it never ships.
ci:
name: CI
uses: $/.github/workflows/ci.yml
publish:
needs: ci
runs-on: ubuntu-latest
outputs:
deploy_tag: ${{ steps.scripts.outputs.deploy_tag }}
timeout-minutes: 30
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# The tags and history, for the scripts version below.
fetch-depth: 0
persist-credentials: false
# The oldest release with this tag's in-game scripts (see the
# script). Empty for a manual dispatch.
- id: scripts
run: |
version=
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
version=$(.github/scripts/scripts-version.sh "$GITHUB_REF_NAME")
fi
echo "Scripts version: ${version:-none}"
echo "version=$version" >> "$GITHUB_OUTPUT"
# The image tag deploy.yml deploys: v1.2.0 -> 1.2.0.
echo "deploy_tag=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
# No QEMU needed for arm64: the Dockerfile installs the packages for
# the target platform on the runner's own CPU and runs nothing in the
# arm64 stage.
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=branch
- uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: server
# arm64 so it also runs on a Raspberry Pi / ARM VPS.
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# vX.Y.Z on a release; a manual dispatch's branch name never
# counts as one (gcm/config.py SERVER_VERSION).
build-args: |
GCM_VERSION=${{ github.ref_name }}
GCM_SCRIPTS_VERSION=${{ steps.scripts.outputs.version }}
# A registry cache rather than type=gha: the Actions cache a tag
# run writes can't be read by the next tag's run, so every
# release would start cold. Spelled out because image refs must
# be lowercase and github.repository isn't.
cache-from: type=registry,ref=ghcr.io/maselkov/gtnh-craft-monitor:buildcache
cache-to: type=registry,ref=ghcr.io/maselkov/gtnh-craft-monitor:buildcache,mode=max
# A GitHub Release for the tag, with notes listing the PRs since the last
# one, so there's a changelog and Watch -> Releases notifies. gcm and the
# Status dialog still find versions by tag, not by release. After publish,
# not deploy: the image is public by then, whatever happens to our server.
release:
name: Release
needs: publish
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# --generate-notes counts from the last *release* by default, and
# older versions have none, so start from the previous version tag.
run: |
prev=$(git describe --tags --abbrev=0 --match 'v[0-9]*' "$GITHUB_REF_NAME^" 2>/dev/null || true)
gh release create "$GITHUB_REF_NAME" --verify-tag --generate-notes \
--title "$GITHUB_REF_NAME" ${prev:+--notes-start-tag "$prev"}
# The exact version this run built, to production (deploy.yml).
deploy:
name: Deploy
needs: publish
# Only release tags deploy; a manual dispatch just publishes the image.
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: read
packages: read
# Without secrets: inherit the called job reads its environment's
# secrets as empty. It only reaches this repo's own deploy.yml, from
# the same commit.
uses: $/.github/workflows/deploy.yml # zizmor: ignore[secrets-inherit]
secrets: inherit
with:
environment: production
tag: ${{ needs.publish.outputs.deploy_tag }}