Skip to content

Commit

Permalink
Update GHA workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Jan 12, 2025
1 parent 6e526d6 commit e355e4d
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 130 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/dependency_graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ on:
workflow_dispatch:

permissions:
# Needed by the dependency-submission action.
contents: write

jobs:
dependency-submission:
dependency_graph:
runs-on: ubuntu-latest
steps:

Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
- "gradle**"
- "*.gradle"
workflow_dispatch:
inputs:
distinct_id:
description: "Automatically set by the return-dispatch action (leave blank if running manually)"
required: false

jobs:
build:
Expand All @@ -29,6 +33,9 @@ jobs:
IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }}
steps:

- name: Echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}

- name: Checkout repository
uses: actions/checkout@v4

Expand Down Expand Up @@ -85,7 +92,6 @@ jobs:

- name: Add VirusTotal links to build summary
if: ${{ env.VIRUSTOTAL_API_KEY && steps.virustotal.outputs.analysis }}
shell: bash
run: |
echo "<details open>" >> $GITHUB_STEP_SUMMARY
echo "<summary>🛡️ VirusTotal Scans</summary>" >> $GITHUB_STEP_SUMMARY
Expand Down Expand Up @@ -122,21 +128,17 @@ jobs:
echo "<details open>" >> $GITHUB_STEP_SUMMARY
echo "<summary>📸 Test Screenshots</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
for img in run/screenshots/*.png; do
if [ -f "$img" ]; then
filename=$(basename "$img")
name_without_ext="${filename%.*}"
# Upload to Imgur
response=$(curl -s -X POST \
-H "Authorization: Client-ID $IMGUR_CLIENT_ID" \
-F "image=@$img" \
https://api.imgur.com/3/image)
# Extract the URL from the response
url=$(echo $response | grep -o '"link":"[^"]*"' | cut -d'"' -f4)
if [ ! -z "$url" ]; then
# Convert underscores to spaces and capitalize first letter of each word
title=$(echo "$name_without_ext" | tr '_' ' ' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
Expand Down
200 changes: 103 additions & 97 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ on:
required: false
type: boolean
default: false
distinct_id:
description: "Automatically set by the return-dispatch action (leave blank if running manually)"
required: false

jobs:
publish:
Expand All @@ -45,100 +48,103 @@ jobs:
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
steps:

- name: Checkout repository
uses: actions/checkout@v4
with:
# Include all tags in case the new tag already exists.
fetch-tags: true

- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "microsoft"

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build
run: ./gradlew build --stacktrace --warning-mode=fail

- name: Create and push tag
run: |
MOD_VERSION=$(grep "^mod_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
git config --global user.name "Wurst-Bot"
git config --global user.email "contact.wurstimperium@gmail.com"
git tag "v$MOD_VERSION"
git push origin "v$MOD_VERSION"
- name: Close milestone
if: ${{ inputs.close_milestone }}
run: ./gradlew closeMilestone --stacktrace

- name: Upload backups
if: ${{ inputs.upload_backups }}
run: ./gradlew uploadBackups --stacktrace

- name: Publish to GitHub
if: ${{ inputs.publish_github }}
env:
GITHUB_TOKEN: ${{ secrets.MCX_PUBLISH_TOKEN }}
run: ./gradlew github --stacktrace

- name: Publish to CurseForge
if: ${{ inputs.publish_curseforge }}
run: ./gradlew publishCurseforge --stacktrace

- name: Get CurseForge file ID
id: cf_file_id
if: ${{ inputs.publish_curseforge }}
run: |
file_id=$(./gradlew getCurseforgeId -x publishCurseforge | grep -o 'CURSEFORGE_FILE_ID=[0-9]*' | grep -o '[0-9]*')
echo "file_id=$file_id" >> "$GITHUB_OUTPUT"
echo "CurseForge file ID: \`$file_id\`" >> $GITHUB_STEP_SUMMARY
- name: Build website update inputs
id: website_inputs
if: ${{ inputs.update_website && inputs.publish_curseforge }}
run: |
MOD_VERSION=$(grep "^mod_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r' | sed 's/-MC.*$//')
MC_VERSION=$(grep "^minecraft_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
FAPI_VERSION=$(grep "^fabric_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
JSON_STRING=$(cat << EOF
{
"mod": "chestesp",
"modloader": "fabric",
"mod_version": "$MOD_VERSION",
"mc_version": "$MC_VERSION",
"fapi_version": "$FAPI_VERSION",
"file_id": "${{ steps.cf_file_id.outputs.file_id }}"
}
EOF
)
# Convert to single line and escape quotes
echo "json=${JSON_STRING//$'\n'/}" >> "$GITHUB_OUTPUT"
- name: Trigger website update
id: website_dispatch
if: ${{ inputs.update_website && inputs.publish_curseforge }}
uses: codex-/return-dispatch@v2
with:
token: ${{ secrets.WIMODS_NET_PUBLISH_TOKEN }}
owner: Wurst-Imperium
repo: wimods.net
ref: master
workflow: add_mod_port.yml
workflow_inputs: ${{ steps.website_inputs.outputs.json }}

- name: Wait for website update to finish (run ${{ steps.website_dispatch.outputs.run_id }})
if: ${{ inputs.update_website && inputs.publish_curseforge }}
uses: codex-/await-remote-run@v1
with:
token: ${{ secrets.WIMODS_NET_PUBLISH_TOKEN }}
owner: Wurst-Imperium
repo: wimods.net
run_id: ${{ steps.website_dispatch.outputs.run_id }}
run_timeout_seconds: 600 # 10 minutes
- name: Echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}

- name: Checkout repository
uses: actions/checkout@v4
with:
# Include all tags in case the new tag already exists.
fetch-tags: true

- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "microsoft"

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build
run: ./gradlew build --stacktrace --warning-mode=fail

- name: Create and push tag
run: |
MOD_VERSION=$(grep "^mod_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
git config --global user.name "Wurst-Bot"
git config --global user.email "contact.wurstimperium@gmail.com"
git tag "v$MOD_VERSION"
git push origin "v$MOD_VERSION"
- name: Close milestone
if: ${{ inputs.close_milestone }}
run: ./gradlew closeMilestone --stacktrace

- name: Upload backups
if: ${{ inputs.upload_backups }}
run: ./gradlew uploadBackups --stacktrace

- name: Publish to GitHub
if: ${{ inputs.publish_github }}
env:
GITHUB_TOKEN: ${{ secrets.MCX_PUBLISH_TOKEN }}
run: ./gradlew github --stacktrace

- name: Publish to CurseForge
if: ${{ inputs.publish_curseforge }}
run: ./gradlew publishCurseforge --stacktrace

- name: Get CurseForge file ID
id: cf_file_id
if: ${{ inputs.publish_curseforge }}
run: |
file_id=$(./gradlew getCurseforgeId -x publishCurseforge | grep -o 'CURSEFORGE_FILE_ID=[0-9]*' | grep -o '[0-9]*')
echo "file_id=$file_id" >> "$GITHUB_OUTPUT"
echo "CurseForge file ID: \`$file_id\`" >> $GITHUB_STEP_SUMMARY
- name: Build website update inputs
id: website_inputs
if: ${{ inputs.update_website && inputs.publish_curseforge }}
run: |
MOD_VERSION=$(grep "^mod_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r' | sed 's/-MC.*$//')
MC_VERSION=$(grep "^minecraft_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
FAPI_VERSION=$(grep "^fabric_version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
JSON_STRING=$(cat << EOF
{
"mod": "chestesp",
"modloader": "fabric",
"mod_version": "$MOD_VERSION",
"mc_version": "$MC_VERSION",
"fapi_version": "$FAPI_VERSION",
"file_id": "${{ steps.cf_file_id.outputs.file_id }}"
}
EOF
)
# Convert to single line and escape quotes
echo "json=${JSON_STRING//$'\n'/}" >> "$GITHUB_OUTPUT"
- name: Trigger website update
id: website_dispatch
if: ${{ inputs.update_website && inputs.publish_curseforge }}
uses: codex-/return-dispatch@v2
with:
token: ${{ secrets.WIMODS_NET_PUBLISH_TOKEN }}
owner: Wurst-Imperium
repo: wimods.net
ref: master
workflow: add_mod_port.yml
workflow_inputs: ${{ steps.website_inputs.outputs.json }}

- name: Wait for website update to finish (run ${{ steps.website_dispatch.outputs.run_id }})
if: ${{ inputs.update_website && inputs.publish_curseforge }}
uses: codex-/await-remote-run@v1
with:
token: ${{ secrets.WIMODS_NET_PUBLISH_TOKEN }}
owner: Wurst-Imperium
repo: wimods.net
run_id: ${{ steps.website_dispatch.outputs.run_id }}
run_timeout_seconds: 600 # 10 minutes
56 changes: 29 additions & 27 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- cron: "30 1 * * 1-5"

permissions:
# Both needed by the stale action.
issues: write
pull-requests: write

Expand All @@ -13,30 +14,31 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Run stale bot
uses: actions/stale@v9
with:
stale-issue-message: |
This issue has been open for a while with no recent activity. If this issue is still important to you, please add a comment within the next 7 days to keep it open. Otherwise, the issue will be automatically closed to free up time for other tasks.
Issues should be closed if:
- They are duplicates of other issues
- There is not enough demand
- They are no longer relevant
- There are not enough details
stale-pr-message: |
This pull request has been open for a while with no recent activity. If you're still working on this or waiting for a review, please add a comment or commit within the next 7 days to keep it open. Otherwise, the pull request will be automatically closed to free up time for other tasks.
Pull requests should be closed if:
- They have been superseded by another pull request
- They are out of scope or don't align with the project
- They have become obsolete due to other changes
- They have bugs or conflicts that won't be resolved
days-before-stale: 60
days-before-close: 7
exempt-issue-labels: "status:never-stale"
exempt-pr-labels: "status:never-stale"
stale-issue-label: "status:stale"
stale-pr-label: "status:stale"
operations-per-run: 30
enable-statistics: true
- name: Run stale action
uses: actions/stale@v9
with:
stale-issue-message: |
This issue has been open for a while with no recent activity. If this issue is still important to you, please add a comment within the next 7 days to keep it open. Otherwise, the issue will be automatically closed to free up time for other tasks.
Issues should be closed if:
- They are duplicates of other issues
- There is not enough demand
- They are no longer relevant
- There are not enough details
stale-pr-message: |
This pull request has been open for a while with no recent activity. If you're still working on this or waiting for a review, please add a comment or commit within the next 7 days to keep it open. Otherwise, the pull request will be automatically closed to free up time for other tasks.
Pull requests should be closed if:
- They have been superseded by another pull request
- They are out of scope or don't align with the project
- They have become obsolete due to other changes
- They have bugs or conflicts that won't be resolved
days-before-stale: 60
days-before-close: 7
exempt-issue-labels: "status:never-stale,status:confirmed"
exempt-pr-labels: "status:never-stale,status:confirmed,status:merged"
exempt-all-milestones: true
stale-issue-label: "status:stale"
stale-pr-label: "status:stale"
operations-per-run: 30
enable-statistics: true

0 comments on commit e355e4d

Please sign in to comment.