Skip to content

Release Creation

Release Creation #11

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: actions/setup-node@v4
# 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"
- name: Get Module JSON
id: set_var
run: |
echo "PACKAGE_JSON=$(jq -c . < module.json)" >> $GITHUB_OUTPUT
- name: Get Module Title
id: title
run: echo "title=${{ fromJson(steps.set_var.outputs.PACKAGE_JSON).title }}" >> "$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 }}
manifest: https://raw.githubusercontent.com/${{ github.repository }}/latest/download/module.json
download: https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/module.zip
- name: Substitute Manifest for Prerelease
if: github.event.release.prerelease
id: sub_prerelease_manifest_version
uses: devops-actions/[email protected]
with:
files: module.json
env:
manifest: https://raw.githubusercontent.com/${{ github.repository }}/next/module.json
- name: Build
env:
IGNORE_CHECKER: ${{ github.event.release.prerelease }}
run: |
npm ci
npm 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/ dist/ README.md LICENSE CHANGELOG.md
- name: Get Changelog Body
id: changelog
uses: release-flow/keep-a-changelog-action@v3
with:
command: query
# Effectively an if else statement: https://docs.github.com/en/actions/learn-github-actions/expressions#example
version: ${{ steps.get-version.outputs.version-without-v }}
- name: Update Release with Files
id: create_version_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
omitDraftDuringUpdate: true
omitPrereleaseDuringUpdate: true
name: ${{ steps.get-version.outputs.version-without-v }}
body: ${{ steps.changelog.outputs.release-notes }}
artifacts: './module.json, ./module.zip'
- name: Publish to FoundryVTT
uses: cs96and/[email protected]
if: ${{ !github.event.release.prerelease && env.PACKAGE_TOKEN }}
env:
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
with:
package-token: ${{ env.PACKAGE_TOKEN }}
manifest-url: https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/module.json
- name: Announce on Discord
uses: Ilshidur/action-discord@master
if: ${{ !github.event.release.prerelease }}
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_USERNAME: ${{ steps.title.outputs.title }}
DISCORD_AVATAR: https://github.com/${{ github.repository }}/blob/main/assets/icon.png?raw=true
with:
args: 'https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/module.json \n ${{ steps.changelog.outputs.release-notes }}'
# 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