Skip to content

0.0.!1

0.0.!1 #5

Workflow file for this run

name: Release Creation
on:
release:
types: [published]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
# get part of the tag after the `v`
- name: Extract tag version number
id: get-version
run: echo "version-without-v=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
# Substitute the Manifest and Download URLs in the `module.json`.
- name: Substitute Manifest and Download Links For Versioned Ones
id: sub_manifest_link_version
uses: devops-actions/[email protected]
with:
files: "module.json"
env:
version: ${{steps.get-version.outputs.version-without-v}}
download: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.zip
- name: Substitute URLs for Prerelease
if: 'github.event.release.prerelease'
id: sub_prerelease_manifest_version
uses: microsoft/variable-substitution@v1
with:
files: "module.json"
env:
manifest: https://raw.githubusercontent.com/${{github.repository}}/next/module.json
download: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.zip
- name: Build
run: |
bun install
bun run build
# Create a folder containing all the module stuff and zip it for the release
- name: Create Zip
run: zip -r9 ./module.zip module.json assets/ lang/ packs/ scripts/ styles/ LICENSE
- name: Update Release with Files
id: create_version_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
omitDraftDuringUpdate: true
omitPrereleaseDuringUpdate: true
artifacts: "./module.json, ./module.zip"
# https://stackoverflow.com/questions/61919141/read-json-file-in-github-actions
- id: set_var
run: |
echo "PACKAGE_JSON=$(jq -c . < module.json)" >> $GITHUB_OUTPUT
- name: Get Module ID
id: module_id
run: echo "module_id=${{fromJson(steps.set_var.outputs.PACKAGE_JSON).id}}" >> "$GITHUB_OUTPUT"
# Publish to FoundryVTT
- name: Publish to Foundry VTT Repo
id: publish_foundry_repo
if: '!github.event.release.prerelease && env.FVTT_USERNAME'
run: npx @ghost-fvtt/foundry-publish
env:
FVTT_MANIFEST_PATH: 'module.json'
FVTT_PACKAGE_ID: ${{steps.module_id.outputs.module_id}}
FVTT_USE_NEW_PACKAGE_ADMINISTRATION_INTERFACE: true
FVTT_USERNAME: ${{ secrets.FOUNDRY_ADMIN_USERNAME }}
FVTT_PASSWORD: ${{ secrets.FOUNDRY_ADMIN_PASSWORD }}
FVTT_MANIFEST_URL: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.json
# Run the following when setting up a repo
# git switch --orphan next && git commit --allow-empty -m "init" && git push -u origin next
- name: Update Prerelease Repository
if: 'github.event.release.prerelease'
run: |
git config --global user.name '${{github.actor}}'
git config --global user.email '${{github.actor}}@users.noreply.github.com'
git add module.json
git stash
git clean -f
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY"
git fetch origin "next"
git switch -c "next" "origin/next"
git checkout stash module.json
git commit -m "${{github.event.release.tag_name}} manifest"
git push -f