diff --git a/.github/actions/s3-upload/action.yaml b/.github/actions/s3-upload/action.yaml new file mode 100644 index 0000000..0034333 --- /dev/null +++ b/.github/actions/s3-upload/action.yaml @@ -0,0 +1,47 @@ +name: 'Upload to S3' +description: 'Upload to S3' +inputs: + source-filename: + description: 'File to upload' + required: true + default: '' + destination-filename: + description: 'Target filename in s3' + required: true + default: '' + host: + description: 'Server endpoint' + required: true + default: 's3.bitfocus.io' + bucket: + description: 'Bucket to upload to' + required: true + default: '' + access-key: + description: 'Access Key' + required: true + default: '' + secret-key: + description: 'Secret Key' + required: true + default: '' +runs: + using: 'composite' + steps: + # Based on https://github.com/kneufeld/minio-put/blob/fe6c40f6fbade3e84926b8131b7eaf45966ff7e5/minio-put.sh + - name: Upload file + shell: bash + run: | + resource="/${{ inputs.bucket }}/${{ inputs.destination-filename }}" + content_type="application/octet-stream" + date=`date -R` + _signature="PUT\n\n${content_type}\n${date}\n${resource}" + signature=`echo -en ${_signature} | openssl sha1 -hmac ${{ inputs.secret-key }} -binary | base64` + + curl -v -X PUT -T "${{ inputs.source-filename }}" \ + --fail \ + -H "Host: ${{ inputs.host }}" \ + -H "Date: ${date}" \ + -H "Content-Type: ${content_type}" \ + -H "Authorization: AWS ${{ inputs.access-key }}:${signature}" \ + https://${{ inputs.host }}${resource} diff --git a/.github/workflows/node.yaml b/.github/workflows/node.yaml index eb82428..3ab9d1c 100644 --- a/.github/workflows/node.yaml +++ b/.github/workflows/node.yaml @@ -35,3 +35,36 @@ jobs: # If the commit is tagged with a version (e.g. "v1.0.0"), # release the app after building release: ${{ startsWith(github.ref, 'refs/tags/v') }} + + - name: Determine files to upload + if: github.ref == 'refs/heads/master' # always publish for just the master branch + id: filenames + shell: bash + run: | + HASH=$(git rev-parse --short HEAD) + COUNT=$(git rev-list --count HEAD) + + if [ "$RUNNER_OS" == "Windows" ]; then + echo ::set-output name=sourcename::"electron-output/companion-satellite-x64.exe" + echo ::set-output name=targetname::"companion-satellite-x64-${COUNT}-${HASH}.exe" + elif [ "$RUNNER_OS" == "macOS" ]; then + echo ::set-output name=sourcename::"electron-output/companion-satellite-x64.dmg" + echo ::set-output name=targetname::"companion-satellite-x64-${COUNT}-${HASH}.dmg" + elif [ "$RUNNER_OS" == "Linux" ]; then + echo ::set-output name=sourcename::"electron-output/companion-satellite-x64.tar.gz" + echo ::set-output name=targetname::"companion-satellite-x64-${COUNT}-${HASH}.tar.gz" + else + echo "$RUNNER_OS not supported" + exit 0 + fi + + - name: Upload app + if: ${{ steps.filenames.outputs.sourcename }} + uses: ./.github/actions/s3-upload + with: + source-filename: ${{ steps.filenames.outputs.sourcename }} + destination-filename: ${{ steps.filenames.outputs.targetname }} + host: ${{ secrets.S3_HOST }} + bucket: ${{ secrets.S3_BUCKET }} + access-key: ${{ secrets.S3_KEY }} + secret-key: ${{ secrets.S3_SECRET }} diff --git a/package.json b/package.json index 985cf6a..63c2e19 100644 --- a/package.json +++ b/package.json @@ -101,10 +101,12 @@ "createStartMenuShortcut": true, "perMachine": true, "oneClick": false, - "allowElevation": true + "allowElevation": true, + "artifactName": "companion-satellite-x64.exe" }, "linux": { - "target": "dir", + "target": "tar.gz", + "artifactName": "companion-satellite-${arch}.tar.gz", "extraFiles": [ { "from": "./node_modules/sharp/vendor/8.10.6/lib",