Skip to content

Commit

Permalink
➕ Add CI release workflow files
Browse files Browse the repository at this point in the history
  • Loading branch information
e-marchand committed Nov 25, 2019
1 parent 329dd5b commit 0150f4f
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 0150f4f

Please sign in to comment.