Skip to content

Commit

Permalink
Create release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
phimage authored Mar 27, 2020
1 parent 955559d commit 0834957
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 0834957

Please sign in to comment.