Skip to content

Commit

Permalink
test upload script
Browse files Browse the repository at this point in the history
  • Loading branch information
troyeguo committed Jan 7, 2024
1 parent ea946b3 commit 9389305
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ name: Download and Upload Release Files

on:
push:
branches: [master]
tags:
# Build on every tag in the form v1.2.3-something.4
- "v*"
pull_request:
branches: [master]
branches:
- master

jobs:
build:
Expand All @@ -17,32 +13,25 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up B2 CLI
uses: actions/setup-node@v2
with:
node-version: "14"
- name: Download release files
run: |
mkdir release_files
cd release_files
curl -LJO https://github.com/${{ github.repository }}/archive/${{ github.ref }}/tar.gz
tar -xzf *.tar.gz --strip-components=1
rm *.tar.gz
- name: Install B2 CLI
run: npm install -g backblaze-b2

- name: Download Release Files
run: |
TAG_NAME=$(echo "${GITHUB_REF}" | sed -e 's/refs\/tags\///g')
RELEASE_ID=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG_NAME}" | jq -r '.id')
ASSETS=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets" | jq -r '.[].browser_download_url')
for ASSET in $ASSETS; do
curl -LOJ "${ASSET}"
done
curl https://f000.backblazeb2.com/file/backblazeb2-public/b2-linux-x86_64 -o b2
chmod +x b2
- name: Create Release Folder in Backblaze
- name: Create or update folder in Backblaze
run: |
TAG_NAME=$(echo "${GITHUB_REF}" | sed -e 's/refs\/tags\///g')
b2 authorize-account "${B2_ACCOUNT_ID}" "${B2_APPLICATION_KEY}"
b2 create-bucket "${B2_BUCKET_NAME}" "${TAG_NAME}"
./b2 authorize-account ${{ secrets.B2_ACCOUNT_ID }} ${{ secrets.B2_APPLICATION_KEY }}
./b2 create-bucket ${{ secrets.B2_BUCKET_NAME }} ${{ github.ref }} allPublic
- name: Upload Release Files to Backblaze
- name: Upload release files to Backblaze
run: |
TAG_NAME=$(echo "${GITHUB_REF}" | sed -e 's/refs\/tags\///g')
b2 authorize-account "${B2_ACCOUNT_ID}" "${B2_APPLICATION_KEY}"
b2 sync --delete --replaceNewer . "b2://${B2_BUCKET_NAME}/${TAG_NAME}"
./b2 authorize-account ${{ secrets.B2_ACCOUNT_ID }} ${{ secrets.B2_APPLICATION_KEY }}
./b2 sync --delete --excludeRegex ".*\.git.*" release_files/ ${{ secrets.B2_BUCKET_NAME }}/${{ github.ref }}

0 comments on commit 9389305

Please sign in to comment.