Skip to content

Commit

Permalink
Update main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster94 committed Oct 6, 2024
1 parent c1375db commit 097ff2d
Showing 1 changed file with 53 additions and 92 deletions.
145 changes: 53 additions & 92 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
#
# - Has the module's entry on FoundryVTT's module administration site
# (https://foundryvtt.com/admin) been updated?
#
name: Create Module Files For GitHub Release

name: Create Module Files For GitHub Release

env:
# The URL used for the module's "Project URL" link on FoundryVTT's website.
Expand All @@ -43,99 +42,61 @@ env:
# 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.
# The URL used for FoundryVTT to download the latest module archive file.
release_module_url: "https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.zip"


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]


jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
runs-on: ubuntu-latest # Use the latest Ubuntu environment

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


# 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
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 }}


# 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.

# Note that `zip` will only emit warnings when a file or directory
# doesn't exist, it will not fail.
- name: Create Module Archive
run: |
zip \
--recurse-paths \
`waterdeep-city-of-splendors.zip` \
./module.zip \
`# The files that will be included.` \
module.json \
README.md \
LICENSE \
images/
scripts/ \
packs/ \
# Don't forget to add a backslash at the end of the line for any
# additional files or directories!

# Update the GitHub release with the manifest and module archive files.
- name: Update Release With Files
id: create_version_release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
name: ${{ github.event.release.name }}
draft: ${{ github.event.release.unpublished }}
prerelease: ${{ github.event.release.prerelease }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: './module.json, ./module.zip'
tag: ${{ github.event.release.tag_name }}
body: ${{ github.event.release.body }}
- name: Checkout repository
uses: actions/checkout@v3 # Updated to use latest Node.js support

- name: Set up Node.js # Set up a Node.js environment
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Get version
id: version
uses: battila7/get-version-action@v3 # Updated to support Node.js 20
with:
file: 'module.json'

- name: Create Module Archive # Create the zip file with all necessary contents
run: |
zip --recurse-paths waterdeep-city-of-splendors.zip \
module.json \
README.md \
LICENSE \
images/ \
scripts/ \
packs/
shell: bash # Set shell to bash

- name: Upload release artifact # Upload the zip file as an artifact
uses: actions/upload-artifact@v3
with:
name: waterdeep-city-of-splendors
path: waterdeep-city-of-splendors.zip

- name: Set environment file for version # Store version for later use
run: echo "version=${{ steps.version.outputs.version }}" >> $GITHUB_ENV

- name: Update Release With Files # Update the GitHub release with the manifest and zip
id: create_version_release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
name: ${{ github.event.release.name }}
draft: ${{ github.event.release.unpublished }}
prerelease: ${{ github.event.release.prerelease }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: './module.json, ./module.zip'
tag: ${{ github.event.release.tag_name }}
body: ${{ github.event.release.body }}

- name: Notify on version bump # Notify version bump log
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: echo "Released Waterdeep City of Splendors v${{ env.version }}"

0 comments on commit 097ff2d

Please sign in to comment.