Files
pack/.gitea/workflows/build-and-release.yml

113 lines
3.3 KiB
YAML

name: Texture Pack Packaging and Release
on:
push:
branches:
- main
- master
jobs:
package-and-release:
runs-on: ubuntu-latest
timeout-minutes: 10
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up ZIP tool
run: sudo apt-get install zip -y
- name: Create version info
id: version
run: |
# Get current date for versioning
DATE=$(date +"%Y.%m.%d")
echo "VERSION=$DATE" >> $GITHUB_ENV
# Update versions.txt
if [ ! -f versions.txt ]; then
echo "Initial version: $DATE" > versions.txt
else
echo "New version: $DATE" >> versions.txt
fi
echo "Pack version: $DATE"
- name: Package texture pack
run: |
# Create ZIP with consistent name
zip -r MineDivinity-Pack.zip \
pack.mcmeta \
pack.png \
assets/ \
LICENSE \
README.md
# Generate SHA1 checksum
sha1sum MineDivinity-Pack.zip > MineDivinity-Pack.zip.sha1
echo "ZIP file created: MineDivinity-Pack.zip"
echo "SHA1 checksum generated"
- name: Configure Git
run: |
git config --global user.name "Gitea Actions"
git config --global user.email "actions@gitea"
git remote set-url origin https://x:${{ secrets.TOKEN }}@git.devbeni.lol/MineDivinity/pack.git
- name: Commit version update
run: |
# Pull changes and handle potential merge conflicts
git pull origin main || true
# If conflict occurs, keep both version entries
if git diff --name-only --diff-filter=U | grep -q "versions.txt"; then
git checkout --ours versions.txt
echo "New version: ${{ env.VERSION }}" >> versions.txt
git add versions.txt
fi
git add versions.txt
git commit -m "Update to version ${{ env.VERSION }} [skip ci]" || echo "No changes to commit"
git push origin main
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: v${{ env.VERSION }}
release_name: MineDivinity Pack v${{ env.VERSION }}
body: |
Minecraft Texture Pack Release
Version: ${{ env.VERSION }}
draft: false
prerelease: false
- name: Upload Artifacts
run: |
echo "Uploading texture pack..."
curl -sSL \
-X POST \
-H "Authorization: token ${{ secrets.TOKEN }}" \
-H "Content-Type: application/zip" \
--data-binary @MineDivinity-Pack.zip \
"${{ steps.create-release.outputs.upload_url }}?name=MineDivinity-Pack.zip"
echo "Uploading SHA1 checksum..."
curl -sSL \
-X POST \
-H "Authorization: token ${{ secrets.TOKEN }}" \
-H "Content-Type: text/plain" \
--data-binary @MineDivinity-Pack.zip.sha1 \
"${{ steps.create-release.outputs.upload_url }}?name=MineDivinity-Pack.zip.sha1"
echo "Artifacts uploaded successfully"