Skip to content

Commit

Permalink
ci: add working dir and some minor changes of create-version.sh (Grep…
Browse files Browse the repository at this point in the history
…timeTeam#2133)

* ci: add context argument in build-greptime-binary action

* refactor: add 'working-dir' in upload-artifacts action and rename 'context' to 'working-dir'

* refactor: use timestamp as part of image tag when trigger manually
  • Loading branch information
zyy17 authored Aug 10, 2023
1 parent 0270708 commit 587a24e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .github/actions/build-greptime-binary/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ inputs:
description: Upload to S3
required: false
default: 'true'
working-dir:
description: Working directory to build the artifacts
required: false
default: .
runs:
using: composite
steps:
- name: Build greptime binary
shell: bash
run: |
cd ${{ inputs.working-dir }} && \
make build-greptime-by-buildx \
CARGO_PROFILE=${{ inputs.cargo-profile }} \
FEATURES=${{ inputs.features }} \
Expand All @@ -54,3 +59,4 @@ runs:
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}
upload-to-s3: ${{ inputs.upload-to-s3 }}
working-dir: ${{ inputs.working-dir }}
8 changes: 8 additions & 0 deletions .github/actions/build-linux-artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ inputs:
description: Upload to S3
required: false
default: 'true'
working-dir:
description: Working directory to build the artifacts
required: false
default: .
runs:
using: composite
steps:
Expand All @@ -41,6 +45,7 @@ runs:
shell: bash
# NOTE: If the BUILD_JOBS > 4, it's always OOM in EC2 instance.
run: |
cd ${{ inputs.working-dir }} && \
make run-it-in-container BUILD_JOBS=4
- name: Upload sqlness logs
Expand All @@ -64,6 +69,7 @@ runs:
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}
upload-to-s3: ${{ inputs.upload-to-s3 }}
working-dir: ${{ inputs.working-dir }}

- name: Build greptime without pyo3
if: ${{ inputs.dev-mode == 'false' }}
Expand All @@ -79,6 +85,7 @@ runs:
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}
upload-to-s3: ${{ inputs.upload-to-s3 }}
working-dir: ${{ inputs.working-dir }}

- name: Build greptime on centos base image
uses: ./.github/actions/build-greptime-binary
Expand All @@ -94,3 +101,4 @@ runs:
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}
upload-to-s3: ${{ inputs.upload-to-s3 }}
working-dir: ${{ inputs.working-dir }}
11 changes: 9 additions & 2 deletions .github/actions/upload-artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ inputs:
description: Upload to S3
required: false
default: 'true'
working-dir:
description: Working directory to upload the artifacts
required: false
default: .
runs:
using: composite
steps:
- name: Create artifacts directory
working-directory: ${{ inputs.working-dir }}
shell: bash
run: |
mkdir -p ${{ inputs.artifacts-dir }} && \
Expand All @@ -41,6 +46,7 @@ runs:
# greptime-linux-amd64-pyo3-v0.3.0
# └── greptime
- name: Compress artifacts and calculate checksum
working-directory: ${{ inputs.working-dir }}
shell: bash
run: |
tar -zcvf ${{ inputs.artifacts-dir }}.tar.gz ${{ inputs.artifacts-dir }} && \
Expand All @@ -52,13 +58,13 @@ runs:
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifacts-dir }}
path: ${{ inputs.artifacts-dir }}.tar.gz
path: ${{ inputs.working-dir }}/${{ inputs.artifacts-dir }}.tar.gz

- name: Upload checksum
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifacts-dir }}.sha256sum
path: ${{ inputs.artifacts-dir }}.sha256sum
path: ${{ inputs.working-dir }}/${{ inputs.artifacts-dir }}.sha256sum

- name: Configure AWS credentials
if: ${{ inputs.upload-to-s3 == 'true' }}
Expand All @@ -70,6 +76,7 @@ runs:

- name: Upload artifacts to S3
if: ${{ inputs.upload-to-s3 == 'true' }}
working-directory: ${{ inputs.working-dir }}
shell: bash
# The bucket layout will be:
# releases/greptimedb
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/create-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function create_version() {
echo "COMMIT_SHA is empty in dev build"
exit 1
fi
echo "dev-$(date "+%Y%m%d%S")-$(echo "$COMMIT_SHA" | cut -c1-8)"
echo "dev-$(date "+%Y%m%d-%s")-$(echo "$COMMIT_SHA" | cut -c1-8)"
exit 0
fi

Expand All @@ -50,7 +50,7 @@ function create_version() {
fi
echo "$GITHUB_REF_NAME"
elif [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then
echo "$NEXT_RELEASE_VERSION-$(git rev-parse --short HEAD)-$(date "+%Y%m%d%S")"
echo "$NEXT_RELEASE_VERSION-$(git rev-parse --short HEAD)-$(date "+%Y%m%d-%s")"
elif [ "$GITHUB_EVENT_NAME" = schedule ]; then
echo "$NEXT_RELEASE_VERSION-$NIGHTLY_RELEASE_PREFIX-$(date "+%Y%m%d")"
else
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ jobs:
path: ${{ env.CHECKOUT_GREPTIMEDB_PATH }}

- uses: ./.github/actions/build-linux-artifacts
working-directory: ${{ env.CHECKOUT_GREPTIMEDB_PATH }}
with:
arch: amd64
cargo-profile: ${{ env.CARGO_PROFILE }}
Expand All @@ -171,6 +170,7 @@ jobs:
aws-region: ${{ vars.AWS_RELEASE_BUCKET_REGION }}
dev-mode: true # Only build the standard greptime binary.
upload-to-s3: false # No need to upload to S3.
working-dir: ${{ env.CHECKOUT_GREPTIMEDB_PATH }}

build-linux-arm64-artifacts:
name: Build linux-arm64 artifacts
Expand All @@ -193,7 +193,6 @@ jobs:
path: ${{ env.CHECKOUT_GREPTIMEDB_PATH }}

- uses: ./.github/actions/build-linux-artifacts
working-directory: ${{ env.CHECKOUT_GREPTIMEDB_PATH }}
with:
arch: arm64
cargo-profile: ${{ env.CARGO_PROFILE }}
Expand All @@ -205,6 +204,7 @@ jobs:
aws-region: ${{ vars.AWS_RELEASE_BUCKET_REGION }}
dev-mode: true # Only build the standard greptime binary.
upload-to-s3: false # No need to upload to S3.
working-dir: ${{ env.CHECKOUT_GREPTIMEDB_PATH }}

release-images-to-dockerhub:
name: Build and push images to DockerHub
Expand Down

0 comments on commit 587a24e

Please sign in to comment.