Fix/build changes #100
Workflow file for this run
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
name: build | |
on: | |
push: | |
branches: | |
- '*' | |
tags: | |
- v*.*.* | |
- v*.*.*-rc.* | |
pull_request: | |
permissions: | |
contents: write | |
env: | |
target-name: hackpackv4 | |
jobs: | |
build-artifacts: | |
name: Build modpack | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Fetch Repo | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # checkout non-detached, so git describe works | |
- name: get go for packwiz | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.20" | |
cache: false # only caches go projects, not general go pkgs | |
- name: get go cache env | |
id: go-cache-env | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "GOMODCACHE<<$EOF" >> $GITHUB_ENV | |
go env GOMODCACHE >> $GITHUB_ENV | |
echo "$EOF" >> $GITHUB_ENV | |
echo "GOCACHE<<$EOF" >> $GITHUB_ENV | |
go env GOCACHE >> $GITHUB_ENV | |
echo "$EOF" >> $GITHUB_ENV | |
- name: cache go | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{env.GOMODCACHE}} | |
${{env.GOCACHE}} | |
key: ${{ runner.os }}-gomod | |
- name: install packwiz | |
run: go install github.com/packwiz/packwiz@latest | |
- name: install dasel | |
run: go install github.com/tomwright/dasel/v2/cmd/[email protected] | |
- name: get base version number | |
id: find_version | |
run: echo "NEW_VERSION=$(git describe --always --tags)" >> $GITHUB_OUTPUT | |
- name: Set new version number (default branch / tagged build) | |
if: ((github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) || (startsWith(github.ref, 'refs/tags/'))) | |
run: | | |
SET_VERSION="${{steps.find_version.outputs.NEW_VERSION}}" | |
sed -i "s~version = \"dev\"~version = \"$SET_VERSION\"~g" pack.toml | |
echo "SET_VERSION=${SET_VERSION}" >> $GITHUB_ENV | |
- name: Set new version number (PR) | |
if: ((github.ref != format('refs/heads/{0}', github.event.repository.default_branch)) && (github.event_name == 'pull_request')) | |
run: | | |
SET_VERSION="${{steps.find_version.outputs.NEW_VERSION}}+PR$(echo "${{ github.ref_name }}" | sed "s~/merge~~g")" | |
sed -i "s~version = \"dev\"~version = \"$SET_VERSION\"~g" pack.toml | |
echo "SET_VERSION=${SET_VERSION}" >> $GITHUB_ENV | |
- name: Set new version number (Other branch) | |
if: ((github.ref != format('refs/heads/{0}', github.event.repository.default_branch)) && (github.event_name != 'pull_request') && !(startsWith(github.ref, 'refs/tags/'))) | |
run: | | |
SET_VERSION="${{steps.find_version.outputs.NEW_VERSION}}+${{ github.ref_name }}" | |
sed -i "s~version = \"dev\"~version = \"$SET_VERSION\"~g" pack.toml | |
echo "SET_VERSION=${SET_VERSION}" >> $GITHUB_ENV | |
- run: | | |
echo "# Version" >> $GITHUB_STEP_SUMMARY | |
echo "${{env.SET_VERSION}}" >> $GITHUB_STEP_SUMMARY | |
- name: generate hashes | |
run: packwiz refresh --build | |
- name: get list of file to upload | |
id: fileindex | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "FILES<<$EOF" >> $GITHUB_OUTPUT | |
dasel -f index.toml -r toml -s "files.all().file" >> $GITHUB_OUTPUT | |
echo "$EOF" >> $GITHUB_OUTPUT | |
- name: upload artifact (packwiz) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "packwiz-modpack" | |
path: | | |
pack.toml | |
index.toml | |
README.md | |
${{ steps.fileindex.outputs.FILES }} | |
- name: Cache Mods | |
id: cache-mods | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/packwiz/cache | |
key: ${{ runner.os }}-packwiz-${{ hashFiles('index.toml') }} | |
restore-keys: ${{ runner.os }}-packwiz | |
- name: build modrinth format modpack | |
run: packwiz modrinth export -o ${{ env.target-name }}.mrpack | |
- name: upload artifact (modrinth) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "modrinth-modpack" | |
path: "${{ env.target-name }}.mrpack" | |
release: | |
needs: build-artifacts | |
if: ${{ github.ref_type == 'tag' }} | |
name: Release to modrinth and github | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Fetch Modrinth Modpack | |
uses: actions/download-artifact@v3 | |
with: | |
name: modrinth-modpack | |
- name: Fetch Packwiz Modpack | |
uses: actions/download-artifact@v3 | |
with: | |
name: packwiz-modpack | |
path: pw-modpack | |
- name: Create ${{ env.target-name }}.packwiz.zip | |
run: zip -rq ${{ env.target-name }}.packwiz pw-modpack/ # ${{ env.target-name }}.packwiz.zip | |
- name: Create Modrinth Release | |
id: modrinth-release | |
if: false | |
uses: Kir-Antipov/[email protected] | |
with: | |
modrinth-id: ${{ secrets.MODRINTH_PROJECT }} | |
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
modrinth-featured: ${{ !(contains(github.ref, '-rc.')) }} | |
modrinth-unfeature-mode: ${{ ((contains(github.ref, '-rc.')) && 'none') || 'any' }} # "any" if production deploy, none otherwise | |
files-primary: "${{ env.target-name }}.mrpack" | |
files-extra: "${{ env.target-name }}.packwiz.zip" | |
version-type: ${{ ((contains(github.ref, '-rc.')) && 'beta') || 'release' }} | |
game-versions: 1.19.4 | |
- name: Create Github Release | |
id: github-release | |
uses: softprops/action-gh-release@v1 | |
with: | |
generate_release_notes: ${{ !(contains(github.ref, '-rc.')) }} | |
prerelease: ${{ contains(github.ref, '-rc.') }} | |
files: | | |
${{ env.target-name }}.mrpack | |
${{ env.target-name }}.packwiz.zip | |
- if: ((steps.github-release.conclusion == 'success') || (steps.modrinth-release.conclusion == 'success')) | |
run: echo "# Releases" >> $GITHUB_STEP_SUMMARY | |
- if: steps.github-release.conclusion == 'success' | |
run: | | |
echo "- [Github](${{ steps.github-release.outputs.url }})" >> $GITHUB_STEP_SUMMARY | |
- if: steps.modrinth-release.conclusion == 'success' | |
run: | | |
echo "- [Modrinth](https://modrinth.com/modpacks/${{secrets.MODRINTH_PROJECT}}/versions)" >> $GITHUB_STEP_SUMMARY | |
deploy: | |
name: Deploy packwiz GH Pages | |
concurrency: ci-${{ github.ref }} | |
runs-on: ubuntu-22.04 | |
needs: build-artifacts | |
if: ${{ github.event_name != 'pull_request' }} | |
env: | |
ghpagebot-name: github-actions[bot] | |
ghpagebot-email: 41898282+github-actions[bot]@users.noreply.github.com | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v3 | |
- name: Fetch Packwiz Modpack | |
uses: actions/download-artifact@v3 | |
with: | |
name: packwiz-modpack | |
path: pw-modpack | |
# if pr, skip. | |
# if branch -> push to branch/branchname | |
# if tag -> push to tag/tagname | |
# if tag -> push to latest | |
# if tag && not rc -> push to stable | |
- name: Deploy production | |
uses: JamesIves/github-pages-deploy-action@v4 | |
if: ${{ github.ref_type == 'branch' }} | |
with: | |
folder: pw-modpack | |
branch: gh-pages | |
target-folder: branch/${{ github.ref_name }} | |
git-config-name: ${{ env.ghpagebot-name }} | |
git-config-email: ${{ env.ghpagebot-email }} | |
- name: Deploy production | |
uses: JamesIves/github-pages-deploy-action@v4 | |
if: ${{ github.ref_type == 'tag' }} | |
with: | |
folder: pw-modpack | |
branch: gh-pages | |
target-folder: tag/${{ github.ref_name }} | |
git-config-name: ${{ env.ghpagebot-name }} | |
git-config-email: ${{ env.ghpagebot-email }} | |
- name: Deploy production | |
uses: JamesIves/github-pages-deploy-action@v4 | |
if: ${{ github.ref_type == 'tag' }} | |
with: | |
folder: pw-modpack | |
branch: gh-pages | |
target-folder: rc | |
git-config-name: ${{ env.ghpagebot-name }} | |
git-config-email: ${{ env.ghpagebot-email }} | |
- name: Deploy production | |
uses: JamesIves/github-pages-deploy-action@v4 | |
if: ${{ github.ref_type == 'tag' && !(contains(github.ref, '-rc.')) }} | |
with: | |
folder: pw-modpack | |
branch: gh-pages | |
target-folder: stable | |
git-config-name: ${{ env.ghpagebot-name }} | |
git-config-email: ${{ env.ghpagebot-email }} | |
# TODO | |
# Generate Changelog | |
# maybe generate a json file in the repo, and a workflow modifies readme.md from the template (so it should never be modified manually) | |
# packwiz list | sort | |
# wc -l -> number of mods | |
# readme.md -> list of mods in current branch? | |
# releases -> full list of mods behind <details><summary> | |
# full release -> diff of mods from last full release | |
# RC release -> diff of mods from last rc / full release | |
# publish readme, licence inside modpack + repo | |
# generated changelog file to be included |