Skip to content

Commit

Permalink
chore(ci): publish binary to repo.databend.rs (databendlabs#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc authored Dec 25, 2023
1 parent 3570b17 commit 7cecacb
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 22 deletions.
56 changes: 56 additions & 0 deletions .github/actions/publish_binary/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 'Publish Binary'
description: 'Publish Binary to GitHub Releases and Cloudflare R2'
inputs:
os:
description: "Operating system"
required: true
target:
description: "Release target"
required: true
version:
description: "Release version"
required: true
runs:
using: "composite"
steps:

- name: Pack binary
id: package
shell: bash
run: |
mkdir -p dist
case ${{ inputs.os }} in
linux)
tar -czf dist/bendsql-${{ inputs.target }}.tar.gz -C target/${{ inputs.target }}/release bendsql
echo "file=bendsql-${{ inputs.target }}.tar.gz" >> $GITHUB_OUTPUT
;;
macos)
tar -czf dist/bendsql-${{ inputs.target }}.tar.gz -C target/${{ inputs.target }}/release bendsql
echo "file=bendsql-${{ inputs.target }}.tar.gz" >> $GITHUB_OUTPUT
;;
windows)
7z a -tzip dist/bendsql-${{ inputs.target }}.zip target/${{ inputs.target }}/release/bendsql.exe
echo "file=bendsql-${{ inputs.target }}.zip" >> $GITHUB_OUTPUT
;;
*)
echo "Unsupported OS: ${{ inputs.os }}"
exit 1
;;
esac
- name: Publish to Github Releases
id: name
shell: bash
run: |
gh release upload ${{ inputs.version }} dist/${{ steps.package.outputs.file }} --clobber
- name: Upload package to Cloudflare R2
id: upload
shell: bash
run: |
aws s3 cp dist/${{ steps.name.outputs.file }} s3://repo/bendsql/${{ inputs.version }}/${{ steps.name.outputs.file }} --no-progress
gh api /repos/datafuselabs/bendsql/tags > tags.json
aws s3 cp ./tags.json s3://repo/bendsql/tags.json
gh api /repos/datafuselabs/bendsql/releases > releases.json
cat releases.json
aws s3 cp ./releases.json s3://repo/bendsql/releases.json
42 changes: 20 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ jobs:
shell: bash
run: |
cross build --release --target=${{ matrix.target }} --bin=bendsql
- name: Publish
shell: bash
- name: Publish Binary
uses: ./.github/actions/publish_binary
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p dist
tar -czf dist/bendsql-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release bendsql
gh release upload ${{ github.ref_name }} dist/bendsql-${{ matrix.target }}.tar.gz --clobber
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: auto
AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }}
with:
os: linux
target: ${{ matrix.target }}
version: ${{ github.ref_name }}

build_other:
name: build ${{ matrix.target }}
Expand All @@ -61,24 +65,18 @@ jobs:
shell: bash
run: |
cargo build --release --target=${{ matrix.target }} --bin=bendsql
- name: Publish macOS
if: matrix.os == 'macos'
shell: bash
- name: Publish Binary
uses: ./.github/actions/publish_binary
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p dist
tar -czf dist/bendsql-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release bendsql
gh release upload ${{ github.ref_name }} dist/bendsql-${{ matrix.target }}.tar.gz --clobber
- name: Publish Windows
if: matrix.os == 'windows'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p dist
7z a -tzip dist/bendsql-${{ matrix.target }}.zip target/${{ matrix.target }}/release/bendsql.exe
gh release upload ${{ github.ref_name }} dist/bendsql-${{ matrix.target }}.zip --clobber
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: auto
AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }}
with:
os: ${{ matrix.os }}
target: ${{ matrix.target }}
version: ${{ github.ref_name }}

distribution:
needs: build_linux
Expand Down

0 comments on commit 7cecacb

Please sign in to comment.