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: Calculate version number id: version run: | # Read current version from versions.txt or initialize if [ -f versions.txt ]; then CURRENT_VERSION=$(tail -1 versions.txt | awk '{print $NF}') else CURRENT_VERSION="1.0.0" echo "Initial version: $CURRENT_VERSION" > versions.txt fi # Split version into components MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1) MINOR=$(echo $CURRENT_VERSION | cut -d. -f2) PATCH=$(echo $CURRENT_VERSION | cut -d. -f3) # Increment version according to rules if [ $PATCH -lt 9 ]; then NEW_PATCH=$((PATCH + 1)) NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" else NEW_MINOR=$((MINOR + 1)) NEW_VERSION="$MAJOR.$NEW_MINOR.0" fi echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV echo "New version: $NEW_VERSION" >> versions.txt echo "New version calculated: $NEW_VERSION" - name: Package texture pack run: | # Create proper Minecraft pack structure mkdir -p temp/pack cp pack/pack.mcmeta temp/pack/ cp pack/pack.png temp/pack/ cp -r pack/assets/ temp/pack/ # Create ZIP with correct structure cd temp && zip -r ../MineDivinity-Pack.zip pack/ cd .. # Generate SHA1 checksum sha1sum MineDivinity-Pack.zip > MineDivinity-Pack.sha1.txt 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: Delete existing tag if present run: | if git rev-parse v${{ env.VERSION }} >/dev/null 2>&1; then git tag -d v${{ env.VERSION }} git push --delete origin v${{ env.VERSION }} || true fi - name: Create Tag run: | git tag -a v${{ env.VERSION }} -m "Release v${{ env.VERSION }}" git push origin v${{ env.VERSION }} - name: Commit version update run: | git pull origin main git add versions.txt git commit -m "Update to version ${{ env.VERSION }} [skip ci]" 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 }} Includes: - Properly structured texture pack - SHA1 checksum for verification 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.sha1.txt \ "${{ steps.create-release.outputs.upload_url }}?name=MineDivinity-Pack.sha1.txt" echo "Artifacts uploaded successfully"