forked from artynova/hexdummy
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f40ef49
commit 575023c
Showing
2 changed files
with
189 additions
and
0 deletions.
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,74 @@ | ||
{% raw %} | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: "*" | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
# add more branches here to enable deploying the web book to Pages from those branches | ||
# eg. '["{% endraw %}{{ default_branch }}{% raw %}", "1.19"]' | ||
MAIN_BRANCHES: '["{% endraw %}{{ default_branch }}{% raw %}"]' | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
is-main-branch: |- | ||
${{ | ||
github.event_name != 'pull_request' | ||
&& contains(fromJson(env.MAIN_BRANCHES), env.BRANCH_NAME) | ||
}} | ||
steps: | ||
- name: Print message so the workflow isn't invalid | ||
run: 'echo "Hello World!"' | ||
|
||
build-mod: | ||
needs: setup | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: {% endraw %}{{ java_version }}{% raw %} | ||
- uses: gradle/actions/setup-gradle@v3 | ||
|
||
- name: Build mod | ||
run: ./gradlew build | ||
|
||
# literally no idea why the mkdir is needed, but the workflow fails without it :/ | ||
- name: Check if datagen needs to be run | ||
timeout-minutes: 3 | ||
run: | | ||
mkdir -p /home/runner/.gradle/caches/fabric-loom/assets | ||
./gradlew runAllDatagen | ||
git add --intent-to-add . | ||
git diff --name-only --exit-code -- ":!:*/src/generated/resources/.cache/*" | ||
|
||
- name: Upload prerelease artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: mod-prerelease | ||
path: build/githubArtifacts/ | ||
if-no-files-found: error | ||
|
||
build-docs: | ||
needs: setup | ||
uses: hexdoc-dev/hexdoc/.github/workflows/hexdoc.yml@v1!0.1.dev | ||
permissions: | ||
contents: write | ||
pages: read | ||
secrets: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
python-version: 3.11 | ||
deploy-pages: ${{ needs.setup.outputs.is-main-branch == 'true' }} | ||
release: false | ||
{% endraw %} |
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,115 @@ | ||
{% raw %} | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
publish-curseforge: | ||
description: Publish to CurseForge | ||
type: boolean | ||
default: false | ||
publish-modrinth: | ||
description: Publish to Modrinth | ||
type: boolean | ||
default: false | ||
publish-github: | ||
description: Publish to GitHub | ||
type: boolean | ||
default: false | ||
publish-docs: | ||
description: Publish the web book | ||
type: boolean | ||
default: false | ||
dry-run: | ||
description: Perform a dry run | ||
type: boolean | ||
default: false | ||
|
||
env: | ||
PYPI_PACKAGE: hexdoc-{% endraw %}{{ modid }}{% raw %} | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build-docs: | ||
uses: hexdoc-dev/hexdoc/.github/workflows/hexdoc.yml@v1!0.1.dev | ||
permissions: | ||
contents: write | ||
pages: read | ||
secrets: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
python-version: 3.11 | ||
deploy-pages: ${{ inputs.publish-docs && !inputs.dry-run }} | ||
release: true | ||
|
||
publish-mod: | ||
needs: build-docs | ||
if: inputs.publish-curseforge || inputs.publish-modrinth || inputs.publish-github | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: curseforge-modrinth | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: {% endraw %}{{ java_version }}{% raw %} | ||
- uses: gradle/actions/setup-gradle@v3 | ||
|
||
- name: Build mod | ||
run: ./gradlew build | ||
|
||
# do this first so we fail if we've already published this version | ||
# because CurseForge and Modrinth apparently don't care! | ||
- name: Publish to GitHub | ||
if: inputs.publish-github | ||
env: | ||
DRY_RUN: ${{ inputs.dry-run && 'true' || '' }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: ./gradlew publishGithub | ||
|
||
- name: Publish to CurseForge | ||
if: inputs.publish-curseforge | ||
env: | ||
DRY_RUN: ${{ inputs.dry-run && 'true' || '' }} | ||
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} | ||
run: ./gradlew publishCurseforge | ||
|
||
- name: Publish to Modrinth | ||
if: inputs.publish-modrinth | ||
env: | ||
DRY_RUN: ${{ inputs.dry-run && 'true' || '' }} | ||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | ||
run: ./gradlew publishModrinth | ||
|
||
- name: Upload dry run artifact | ||
if: inputs.dry-run | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: mod-publish | ||
path: '*/build/publishMods' | ||
if-no-files-found: error | ||
|
||
publish-docs: | ||
needs: build-docs | ||
if: inputs.publish-docs && !inputs.dry-run | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/${{ env.PYPI_PACKAGE }} | ||
permissions: | ||
id-token: write | ||
steps: | ||
# hexdoc workflow uses v3, so we can't use v4 here | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: hexdoc-build | ||
path: dist | ||
|
||
- name: Publish to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
{% endraw %} |