Upload Preview #9
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: Upload Preview | |
on: | |
workflow_dispatch: | |
inputs: | |
runId: | |
required: true | |
description: 'ID of the action to pull artifacts from' | |
version: | |
required: true | |
description: 'Version under which to upload to the Downloads API' | |
jobs: | |
upload: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 | |
with: | |
run-id: ${{ github.event.inputs.runId }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
merge-multiple: true | |
- name: 'List Artifacts' | |
run: | | |
ls -a | |
- name: Get Preview Metadata | |
#if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }} | |
uses: Kas-tle/base-release-action@664c39985eb9d0d393ce98e7eb8414d3d98e762a | |
with: | |
appID: ${{ secrets.RELEASE_APP_ID }} | |
appPrivateKey: ${{ secrets.RELEASE_APP_PK }} | |
files: | | |
bungeecord:Geyser-BungeeCord.jar | |
fabric:Geyser-Fabric.jar | |
neoforge:Geyser-NeoForge.jar | |
spigot:Geyser-Spigot.jar | |
standalone:Geyser-Standalone.jar | |
velocity:Geyser-Velocity.jar | |
viaproxy:Geyser-ViaProxy.jar | |
releaseEnabled: false | |
saveMetadata: true | |
updateReleaseData: false | |
- run: | | |
cat metadata.json | |
echo | |
jq --arg project "geyser-preview" --arg version "pr.${{ github.event.inputs.version }}" --arg number "${{ github.event.inputs.runId }}" ' | |
. | |
| .downloads |= map_values({"name", "sha256"}) | |
| {$project, "repo", $version, "number": $number | tonumber, "changes": [], "downloads"} | |
' metadata.json | |
- name: Publish to Downloads API | |
if: ${{ success() && github.repository == 'GeyserMC/Geyser' && 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_ID: ${{ github.event.inputs.runId }} | |
VERSION: ${{ github.event.inputs.version }} | |
run: | | |
# Save the private key to a file | |
echo "$DOWNLOADS_PRIVATE_KEY" > id_ecdsa | |
chmod 600 id_ecdsa | |
# Set the project | |
project=geyser-preview | |
# Create the build folder | |
ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP mkdir -p "~/uploads/$project/$RUN_ID/" | |
# Copy over artifacts | |
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" Geyser-*.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$project/$RUN_ID/ | |
# Run the build script | |
# Push the metadata | |
jq -c --arg project "${project}" --arg version "${VERSION}" --arg number "${RUN_ID}" ' | |
. | |
| .downloads |= map_values({"name", "sha256"}) | |
| {$project, "repo", $version, "number": $number | tonumber, "changes": [], "downloads"} | |
' metadata.json > metadata.json.tmp && mv metadata.json.tmp metadata.json | |
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" metadata.json $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$project/$RUN_ID/ |