diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5972b74 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: release +on: + release: + types: [published] + +jobs: + update: + name: build + runs-on: macOS-latest + steps: + - name: ⬇️ Checkout + uses: actions/checkout@master + with: + fetch-depth: 1 + - name: 🏗 swiftbuild + run: | + swift build -c debug + - name: 📦 Build archive + run: | + REPOSITORY_NAME=$(jq --raw-output '.repository.name' $GITHUB_EVENT_PATH) + zip -r $REPOSITORY_NAME.zip .build/debug/$REPOSITORY_NAME + - 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 }}