Skip to content

Commit

Permalink
Oops, accidentally a whole module
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Nov 19, 2023
1 parent 56d2457 commit 13ea948
Show file tree
Hide file tree
Showing 35 changed files with 16,974 additions and 166 deletions.
193 changes: 72 additions & 121 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,144 +1,95 @@
# GitHub Actions workflow for creating a new FoundryVTT module release.
#
# Useful References:
# - https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
# - https://docs.github.com/en/actions/learn-github-actions/contexts
# - https://docs.github.com/en/actions/learn-github-actions/environment-variables
#
# Troubleshooting Checklist:
# - Is the module's manifest file valid JSON?
# You can test your manifest file using https://jsonlint.com/.
#
# - Does the module's manifest have all the required keys?
# See https://foundryvtt.com/article/module-development/#manifest for more
# information.
#
# - Are all the proper files and directories being included in the release's
# module archive ("module.zip")?
# Check that the correct files are being passed to the `zip` command run
# in the "Create Module Archive" step below.
#
# - Is the release tag the proper format?
# See the comments for the "Extract Version From Tag" step below.
#
# - Is a GitHub release being published?
# This workflow will only run when a release is published, not when a
# release is updated. Furthermore, note that while a GitHub release will
# (by default) create a repository tag, a repository tag will not create
# or publish a GitHub release.
#
# - Has the module's entry on FoundryVTT's module administration site
# (https://foundryvtt.com/admin) been updated?
#
name: Create Module Files For GitHub Release


env:
# The URL used for the module's "Project URL" link on FoundryVTT's website.
project_url: "https://github.com/${{github.repository}}"

# A URL that will always point to the latest manifest.
# FoundryVTT uses this URL to check whether the current module version that
# is installed is the latest version. This URL should NOT change,
# otherwise FoundryVTT won't be able to perform this check.
latest_manifest_url: "https://github.com/${{github.repository}}/releases/latest/download/module.json"

# The URL to the module archive associated with the module release being
# processed by this workflow.
release_module_url: "https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.zip"

name: Release Creation

on:
# Only run this workflow when a release is published.
# To modify this workflow when other events occur, see:
# - https://docs.github.com/en/actions/using-workflows/triggering-a-workflow
# - https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
# - https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
#
# Note that some steps may depend on context variables that are only
# available for release events, so if you add other events, you may need to
# alter other parts of this workflow.
release:
types: [published]

types: [ published ]

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4


# Extract version embedded in the tag.
# This step expects the tag to be one of the following formats:
# - "v<major>.<minor>.<patch>" (e.g., "v1.2.3")
# - "<major>.<minor>.<patch>" (e.g., "1.2.3")
#
# The version will be used by later steps to fill in the value for the
# "version" key required for a valid module manifest.
- name: Extract Version From Tag
id: get_version
uses: battila7/get-version-action@v2


# Modify "module.json" with values specific to the release.
# Since the values for the "version" and "url" keys aren't known ahead of
# time, the manifest file in the repository is updated with these values.
#
# While this does modify the manifest file in-place, the changes are not
# commited to the repository, and only exist in the action's filesystem.
- name: Modify Module Manifest With Release-Specific Values
id: sub_manifest_link_version
uses: cschleiden/replace-tokens@v1
- uses: actions/checkout@v2

# Substitute the Manifest and Download URLs in the module.json
# for a FULL RELEASE
- name: Substitute Manifest and Download Links For Versioned Ones
if: "!github.event.release.prerelease"
id: sub_release_manifest_version
uses: microsoft/variable-substitution@v1
with:
files: 'module.json'
env:
VERSION: ${{steps.get_version.outputs.version-without-v}}
URL: ${{ env.project_url }}
MANIFEST: ${{ env.latest_manifest_url }}
DOWNLOAD: ${{ env.release_module_url }}
version: ${{github.event.release.tag_name}}
url: https://github.com/${{github.repository}}
manifest: https://github.com/${{github.repository}}/releases/latest/download/module.json
download: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.zip

# Substitute the Manifest and Download URLs in the module.json
# for a PRE RELEASE. Manifest pointing to live module.json on branch,
# which is updated after tag.
- name: Substitute Manifest and Download Links For Versioned Ones
if: "github.event.release.prerelease"
id: sub_prerelease_manifest_version
uses: microsoft/variable-substitution@v1
with:
files: 'module.json'
env:
version: ${{github.event.release.tag_name}}
url: https://github.com/${{github.repository}}
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

# Install packages.
- run: npm install

# Create a "module.zip" archive containing all the module's required files.
# If you have other directories or files that will need to be added to
# your packaged module, add them here.
- name: Create Module Archive
run: |
# Note that `zip` will only emit warnings when a file or directory
# doesn't exist, it will not fail.
zip \
`# Options` \
--recurse-paths \
`# The name of the output file` \
./module.zip \
`# The files that will be included.` \
module.json \
README.md \
LICENSE \
templates \
scripts/ \
styles/ \
packs/ \
language/ \
lang/
# Don't forget to add a backslash at the end of the line for any
# additional files or directories!
# Build distribution.
- run: npm run build

# Create a zip file with all files required by the module to add to the release
- run: zip -r ./module.zip module.json LICENSE module.js module.js.map style.css languages/

# Update the GitHub release with the manifest and module archive files.
- name: Update Release With Files
# Create a release for this specific version
- name: Update Release with Files
if: "!github.event.release.prerelease"
id: create_version_release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
allowUpdates: true # Set this to false if you want to prevent updating existing releases
name: ${{ github.event.release.name }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: './module.json, ./module.zip'
tag: ${{ github.event.release.tag_name }}
body: ${{ github.event.release.body }}

# OR create a pre-release for this specific version
- name: Update Release with Files
if: "github.event.release.prerelease"
id: create_version_prerelease
uses: ncipollo/release-action@v1
with:
allowUpdates: true # Set this to false if you want to prevent updating existing releases
name: ${{ github.event.release.name }}
draft: ${{ github.event.release.unpublished }}
prerelease: ${{ github.event.release.prerelease }}
draft: false
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: './module.json, ./module.zip'
tag: ${{ github.event.release.tag_name }}
body: ${{ github.event.release.body }}

#update next branch
- name: Prepare 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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.idea/*
node_modules/*
dist/*
.vite-cache/*
module.js
module.js.map
style.css
76 changes: 38 additions & 38 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
{
"id": "module",
"title": "New Module",
"description": "",
"version": "#{VERSION}#",
"id": "item_piles_auctioneer",
"title": "Item Piles: Auctioneer",
"description": "This module extends the Item Piles module to add support for an auctioneer NPC where players can buy and sell items among each other.",
"version": "100.0.0",
"library": "false",
"manifestPlusVersion": "1.2.0",
"minimumCoreVersion": "11",
"compatibility": {
"minimum": 10,
"verified": 10,
"maximum": 11
"minimum": "10",
"verified": "11",
"maximum": "11"
},
"authors": [
{
"name": "The League of Extraordinary FVTT Developers",
"url": "https://github.com/League-of-Foundry-Developers",
"discord": "discordID#0001"
"name": "Wasp",
"url": "https://github.com/Haxxer",
"discord": "Wasp#2005"
}
],
"relationships": {
"systems": [],
"requires": []
},
"packs": [],
"esmodules": [
"scripts/module.js"
],
"scripts": [
"scripts/lib/lib.js"
"module.js"
],
"styles": [
"styles/module.css"
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "languages/en.json"
}
"style.css"
],
"url": "#{URL}#",
"manifest": "#{MANIFEST}#",
"download": "#{DOWNLOAD}#",
"license": "LICENSE",
"readme": "README.md",
"media": [
{
"type": "icon",
"url": "https://avatars2.githubusercontent.com/u/71292812?s=400&u=ccdb4eeb7abf551ca8f314e5a9bfd0479a4d3d41&v=4"
}
]
"languages": [],
"relationships": {
"requires": [
{
"id": "item-piles",
"type": "module",
"compatibility": {
"minimum": "2.8.1",
"verified": "2.8.1"
}
},
{
"id": "socketlib",
"type": "module"
}
]
},
"socket": true,
"url": "https://github.com/fantasycalendar/FoundryVTT-Auctioneer",
"manifest": "https://github.com/fantasycalendar/FoundryVTT-Auctioneer/releases/latest/download/manifest.json",
"download": "https://github.com/fantasycalendar/FoundryVTT-Auctioneer/releases/latest/download/module.zip",
"readme": "https://github.com/fantasycalendar/FoundryVTT-Auctioneer/blob/master/README.md",
"bugs": "https://github.com/fantasycalendar/FoundryVTT-Auctioneer/issues",
"allowBugReporter": true
}
Loading

0 comments on commit 13ea948

Please sign in to comment.