Skip to content

Commit 6c2bafe

Browse files
committed
➕ Add CI release workflow file
1 parent b095246 commit 6c2bafe

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Upload artifact
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
publish:
7+
name: Publish
8+
runs-on: macOS-latest
9+
steps:
10+
- name: ⬇️ Checkout
11+
uses: actions/checkout@master
12+
- name: 📦 Build archive
13+
run: |
14+
REPOSITORY_NAME=$(jq --raw-output '.repository.name' $GITHUB_EVENT_PATH)
15+
zip -r $REPOSITORY_NAME.zip . -x ".*" -x "__MACOSX"
16+
- name: ⬆️ Upload to Release
17+
run: |
18+
REPOSITORY_NAME=$(jq --raw-output '.repository.name' $GITHUB_EVENT_PATH)
19+
ARTIFACT=./$REPOSITORY_NAME.zip
20+
AUTH_HEADER="Authorization: token $GITHUB_TOKEN"
21+
CONTENT_LENGTH_HEADER="Content-Length: $(stat -f%z "$ARTIFACT")"
22+
CONTENT_TYPE_HEADER="Content-Type: application/zip"
23+
RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH)
24+
FILENAME=$(basename $ARTIFACT)
25+
UPLOAD_URL="https://uploads.github.com/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets?name=$FILENAME"
26+
echo "$UPLOAD_URL"
27+
curl -sSL -XPOST \
28+
-H "$AUTH_HEADER" -H "$CONTENT_LENGTH_HEADER" -H "$CONTENT_TYPE_HEADER" \
29+
--upload-file "$ARTIFACT" "$UPLOAD_URL"
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)