From 0150f4faa7e42e1db5edbc9d7c550a3aafcda714 Mon Sep 17 00:00:00 2001 From: Eric Marchand Date: Mon, 25 Nov 2019 10:48:35 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20Add=20CI=20release=20workflow=20fil?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3cd33ea --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Upload artifact +on: + release: + types: [published] +jobs: + publish: + name: Publish + runs-on: macOS-latest + steps: + - name: ⬇️ Checkout + uses: actions/checkout@master + - name: 📝 Edit manifest + run: | + echo "Edit manifest to release and repository metadata" + GITHUB_URL="https://github.com/$GITHUB_REPOSITORY" + echo "➕ home page: $GITHUB_URL" + cat <<< "$(jq ".homepage = \"$GITHUB_URL\"" < manifest.json)" > manifest.json + REPOSITORY_NAME=$(jq --raw-output '.repository.name' $GITHUB_EVENT_PATH) + DOWNLOAD_URL="$GITHUB_URL/releases/latest/download/$REPOSITORY_NAME.zip" + echo "➕update url: $DOWNLOAD_URL" + cat <<< "$(jq ".updateURL = \"$DOWNLOAD_URL\"" < manifest.json)" > manifest.json + RELEASE_TAG=$(jq --raw-output '.release.tag_name' $GITHUB_EVENT_PATH) + echo "➕ tag: $RELEASE_TAG" + cat <<< "$(jq ".version = \"$RELEASE_TAG\"" < manifest.json)" > manifest.json + + jq -s '.[0] * .[1]' manifest.json $GITHUB_EVENT_PATH > manifest.merged.json + rm manifest.json + mv manifest.merged.json manifest.json + - name: 📦 Build archive + run: | + REPOSITORY_NAME=$(jq --raw-output '.repository.name' $GITHUB_EVENT_PATH) + zip -r $REPOSITORY_NAME.zip . -x ".*" -x "__MACOSX" + - name: ⬆️ Upload to Release + run: | + REPOSITORY_NAME=$(jq --raw-output '.repository.name' $GITHUB_EVENT_PATH) + ARTIFACT=./$REPOSITORY_NAME.zip + AUTH_HEADER="Authorization: token $GITHUB_TOKEN" + CONTENT_LENGTH_HEADER="Content-Length: $(stat -f%z "$ARTIFACT")" + CONTENT_TYPE_HEADER="Content-Type: application/zip" + RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH) + FILENAME=$(basename $ARTIFACT) + UPLOAD_URL="https://uploads.github.com/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets?name=$FILENAME" + echo "$UPLOAD_URL" + curl -sSL -XPOST \ + -H "$AUTH_HEADER" -H "$CONTENT_LENGTH_HEADER" -H "$CONTENT_TYPE_HEADER" \ + --upload-file "$ARTIFACT" "$UPLOAD_URL" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}