diff --git a/.github/workflows/rw-symbols-upload.yml b/.github/workflows/rw-symbols-upload.yml new file mode 100644 index 0000000..b25241a --- /dev/null +++ b/.github/workflows/rw-symbols-upload.yml @@ -0,0 +1,65 @@ +name: Symbols Upload + +# Upload the content of an artifact to the symbol server. + +on: + workflow_call: + inputs: + artifact-name: + description: The name of the artifact to download. + required: true + type: string + repository: + description: The repository (without owner) doing the uploading. + required: true + type: string + secrets: + SYMBOLS_SIGNING_KEY: + description: The signing key for the Symbol server. + required: true + +jobs: + symbols_upload: + runs-on: ubuntu-latest + name: Symbols upload + + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.artifact-name }} + path: artifact + + - name: Install mimetype + shell: bash + run: | + sudo apt update + sudo apt install -y libfile-mimeinfo-perl --no-install-recommends + + - name: Publish + env: + SYMBOLS_SIGNING_KEY: ${{ secrets.SYMBOLS_SIGNING_KEY }} + shell: bash + run: | + echo "${SYMBOLS_SIGNING_KEY}" > symbols_signing_key.pem + + cd artifact + + for i in $(find -type f | cut -b 3-); do + echo "Uploading ${i} ..." + + FILENAME="${i}" + SIGNATURE=$(echo -n "${FILENAME}" | openssl dgst -sha256 -sign ../symbols_signing_key.pem | base64 -w0) + CONTENT_TYPE=$(mimetype -b ${i}) + + curl \ + -s \ + --fail \ + -X PUT \ + -T ${i} \ + -H "Content-Type: ${CONTENT_TYPE}" \ + -H "X-Signature: ${SIGNATURE}" \ + -H "X-Repository: ${{ inputs.repository }}" \ + -H "User-Agent: symbols-upload/1.0" \ + https://symbols.openttd.org/${FILENAME} + done diff --git a/README.md b/README.md index 3608c1f..6bf039a 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,4 @@ job: - [Python - Black](.github/workflows/rw-py-black.yml): Runs "black" over the code. - [Python - CodeQL](.github/workflows/rw-py-codeql.yml): Runs "CodeQL" over the code. - [Python - Flake8](.github/workflows/rw-py-flake8.yml): Runs "flake8" over the code. +- [Symbols - upload](.github/workflows/rw-symbols-upload.yml): Upload the content of an artifact to the Symbol Server.