Skip to content

Xodium CI/CD

Xodium CI/CD #140

Workflow file for this run

name: Xodium CI/CD
on:
push:
branches: [main]
paths:
- "irp/**"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
name: Release
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name }}
url: ${{ steps.create_release.outputs.url }}
outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}
SHA1: ${{ steps.calculate_sha1.outputs.SHA1 }}
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- id: get_version
name: Get Version
run: echo "VERSION=$(jq -r '.version' version.json)" >> $GITHUB_OUTPUT
- id: packsquash
name: Create Zip & Optimize with Packsquash
uses: ComunidadAylas/PackSquash-action@v4.0.3
with:
packsquash_version: latest
options: |
pack_directory = 'irp'
output_file_path = 'irp_${{ steps.get_version.outputs.VERSION }}.zip'
- id: calculate_sha1
name: Calculate SHA1
run: echo "SHA1=$(sha1sum "irp_${{ steps.get_version.outputs.VERSION }}.zip" | awk '{ print $1 }')" >> $GITHUB_OUTPUT
- id: create_release
name: Create Release
uses: softprops/action-gh-release@v2.3.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: ${{ contains(github.event.head_commit.message, '.draft') }}
files: irp_${{ steps.get_version.outputs.VERSION }}.zip
body: |
Direct Download Link: https://github.com/${{ github.repository }}/releases/download/${{ steps.get_version.outputs.VERSION }}/irp_${{ steps.get_version.outputs.VERSION }}.zip
SHA-1 Hash: ${{ steps.calculate_sha1.outputs.SHA1 }}
generate_release_notes: true
prerelease: ${{ contains(github.event.head_commit.message, '.pre') }}
tag_name: ${{ steps.get_version.outputs.VERSION }}
- id: deploy
name: Deploy to Server
if: success()
env:
SFTP_USER: ${{ secrets.SFTP_USER }}
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_PORT: ${{ secrets.SFTP_PORT }}
SFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }}
SERVER_PROPERTIES_PATH: ${{ secrets.SERVER_PROPERTIES_PATH }}
RESOURCE_PACK_URL: https://github.com/${{ github.repository }}/releases/download/${{ steps.get_version.outputs.VERSION }}/irp_${{ steps.get_version.outputs.VERSION }}.zip
run: |
# Install lftp (SFTP client)
sudo apt-get update && sudo apt-get install -y lftp
# Download with error handling
lftp -u "$SFTP_USER,$SFTP_PASSWORD" -p $SFTP_PORT sftp://$SFTP_HOST <<EOF
get $SERVER_PROPERTIES_PATH
quit
EOF
then
echo "❌ Failed to download server.properties"
exit 1
fi
# Verify download
if [ ! -f "./server.properties.tmp" ]; then
echo "::error::❌ Downloaded file missing"
exit 1
fi
# Modify in-place
sed -i \
-e "s|^resource-pack=.*|resource-pack=$RESOURCE_PACK_URL|" \
-e "s|^resource-pack-sha1=.*|resource-pack-sha1=${{ steps.calculate_sha1.outputs.SHA1 }}|" \
./server.properties.tmp
# Upload back to server
if ! lftp -u "$SFTP_USER,$SFTP_PASSWORD" -p $SFTP_PORT sftp://$SFTP_HOST <<EOF
put ./server.properties.tmp -o $SERVER_PROPERTIES_PATH
quit
EOF
then
echo "::error::❌ Failed to upload server.properties"
exit 1
fi
# Cleanup
rm -f ./server.properties.tmp
echo "✅ Successfully updated $SERVER_PROPERTIES_PATH"