Update release metadata gen #8
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: | |
workflow_dispatch: | |
push: | |
paths-ignore: | |
- '.gitignore' | |
- 'LICENSE' | |
- 'README.md' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
PROJECT: 'geyseroptionalpack' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Prepare pack | |
run: bash prepare_pack.sh | |
- name: Zip pack | |
run: zip GeyserOptionalPack.mcpack -r . -x ".*" required_files.txt prepare_pack.sh | |
- name: Archive artifacts | |
uses: actions/upload-artifact@v3 | |
if: success() | |
with: | |
name: GeyserOptionalPack | |
path: GeyserOptionalPack.mcpack | |
- name: Get Release Metadata | |
if: ${{ success() && github.repository == 'GeyserMC/GeyserOptionalPack' && github.ref_name == 'master' }} | |
uses: Kas-tle/base-release-action@b863fa0f89bd15267a96a72efb84aec25f168d4c # https://github.com/Kas-tle/base-release-action/releases/tag/main-11 | |
with: | |
appID: ${{ secrets.RELEASE_APP_ID }} | |
appPrivateKey: ${{ secrets.RELEASE_APP_PK }} | |
files: | | |
geyseroptionalpack:GeyserOptionalPack.mcpack | |
releaseEnabled: false | |
saveMetadata: true | |
- name: Update Generated Metadata | |
if: ${{ success() && github.repository == 'GeyserMC/GeyserOptionalPack' && github.ref_name == 'master' }} | |
run: | | |
cat metadata.json | |
echo | |
version=$(cat manifest.json | jq -r '.header.version | join(".")') | |
echo "Version: ${version}" | |
cat metadata.json | jq --arg project "${PROJECT}" --arg version "${version}" ' | |
. | |
| .changes |= map({"commit", "summary", "message"}) | |
| .downloads |= map_values({"name", "sha256"}) | |
| {$project, "repo", $version, "number": .build, "changes", "downloads"} | |
' | tee metadata.json | |
echo "" | |
- name: Publish to Downloads API | |
if: ${{ success() && github.repository == 'GeyserMC/GeyserOptionalPack' && github.ref_name == 'master' }} | |
shell: bash | |
env: | |
DOWNLOADS_USERNAME: ${{ vars.DOWNLOADS_USERNAME }} | |
DOWNLOADS_PRIVATE_KEY: ${{ secrets.DOWNLOADS_PRIVATE_KEY }} | |
DOWNLOADS_SERVER_IP: ${{ secrets.DOWNLOADS_SERVER_IP }} | |
run: | | |
# Save the private key to a file | |
echo "$DOWNLOADS_PRIVATE_KEY" > id_ecdsa | |
chmod 600 id_ecdsa | |
# Create the build folder | |
ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP mkdir -p "~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/" | |
# Copy over artifacts | |
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" GeyserOptionalPack.mcpack $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/ | |
# Run the build script | |
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" metadata.json $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER |