-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci(release): add github actions #1445
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
# 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 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/system.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}}/system.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 | ||
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: "system.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. | ||
- 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` \ | ||
./system.zip \ | ||
`# The files that will be included.` \ | ||
fonts/ \ | ||
images/ \ | ||
lang/ \ | ||
lib/ \ | ||
modules/ \ | ||
styles/ \ | ||
templates/ \ | ||
CHANGELOG.md \ | ||
CONTRIBUTING.md \ | ||
LICENSE.txt \ | ||
README.md \ | ||
package.json \ | ||
system.json \ | ||
template.json | ||
# 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: "./system.json, ./system.zip" | ||
tag: ${{ github.event.release.tag_name }} | ||
body: ${{ github.event.release.body }} | ||
- name: Publish System to FoundryVTT Website | ||
id: publish-to-foundry-website | ||
uses: cs96and/FoundryVTT-release-package@v1 | ||
with: | ||
package-token: ${{ secrets.PACKAGE_TOKEN }} | ||
manifest-url: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/system.json | ||
notes-url: https://github.com/${{github.repository}}/releases/tag/${{github.event.release.tag_name}} | ||
dry-run: true |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to generate this secret or does it exist in the GitHub repo by default?