Skip to content

Xodium CI/CD

Xodium CI/CD #80

Workflow file for this run

name: Xodium CI/CD
run-name: "Xodium CI/CD"
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write
packages: 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@main
- id: get_version
name: Get Version
run: echo "VERSION=$(jq -r '.version' version.json)" >> $GITHUB_OUTPUT
- id: create_zip
name: Create Zip File
run: |
mkdir -p temp
cd illyriarp
zip -r "../temp/IllyriaRP_${{ steps.get_version.outputs.VERSION }}.zip" assets pack.mcmeta pack.png
- id: calculate_sha1
name: Calculate SHA1
run: echo "SHA1=$(sha1sum "temp/IllyriaRP_${{ steps.get_version.outputs.VERSION }}.zip" | awk '{ print $1 }')" >> $GITHUB_OUTPUT
- id: create_release
name: Create Release
uses: softprops/action-gh-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: ${{ contains(github.event.head_commit.message, '.draft') }}
files: temp/IllyriaRP_${{ steps.get_version.outputs.VERSION }}.zip
body: |
Direct Download Link: https://github.com/${{ github.repository }}/releases/download/${{ steps.get_version.outputs.VERSION }}/IllyriaRP_${{ 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 }}
update_server_properties:
name: Update Server Properties
runs-on: [ubuntu-latest]
needs: [release]
steps:
- id: install_ssh_client
name: Install SSH Client
run: sudo apt-get install -y openssh-client
- id: update_server_properties
name: Update server.properties
env:
SFTP_SERVER: ${{ secrets.SFTP_SERVER }}
SFTP_USERNAME: ${{ secrets.SFTP_USERNAME }}
SFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }}
VERSION: ${{ needs.release.outputs.VERSION }}
SHA1: ${{ needs.release.outputs.SHA1 }}
run: |
echo "Updating server.properties with new values..."
sftp -P $SFTP_SERVER_PORT $SFTP_USERNAME@$SFTP_SERVER <<EOF
get /server.properties server.properties
bye
EOF
sed -i "s|resource-pack=.*|resource-pack=https://github.com/${{ github.repository }}/releases/download/${{ needs.release.outputs.VERSION }}/IllyriaRP_${{ needs.release.outputs.VERSION }}.zip|" server.properties
sed -i "s|resource-pack-sha1=.*|resource-pack-sha1=${{ needs.release.outputs.SHA1 }}|" server.properties
sftp -P $SFTP_SERVER_PORT $SFTP_USERNAME@$SFTP_SERVER <<EOF
put server.properties /server.properties
bye
EOF