From 27eedd5f3f3bd7a352b73e73a98f3277814fd13f Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 25 Dec 2023 22:53:10 -0800 Subject: [PATCH] modify CI --- .github/workflows/ci.yml | 12 ++++++--- .github/workflows/release.yml | 51 +++++++++++++++++++++++++++++++++++ tools/bazel | 7 ++--- 3 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 013787a..bc78362 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: os: [ubuntu-latest] steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Run Linters shell: bash @@ -19,12 +19,16 @@ jobs: - name: Build Linux X86 64 binary shell: bash - run: tools/bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //bazel_disk_cache_cleaner + run: | + tools/bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //bazel_disk_cache_cleaner + mv bazel-bin/bazel_disk_cache_cleaner/bazel_disk_cache_cleaner_/bazel_disk_cache_cleaner /tmp/bazel_disk_cache_cleaner_linux_amd64 - name: Build Darwin arm 64 binary shell: bash - run: tools/bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_arm64 //bazel_disk_cache_cleaner + run: | + tools/bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_arm64 //bazel_disk_cache_cleaner - name: Build Darwin X86 64 binary shell: bash - run: tools/bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 //bazel_disk_cache_cleaner + run: | + tools/bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 //bazel_disk_cache_cleaner \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e9ef26e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Create Release + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build Linux X86 64 binary + shell: bash + run: | + tools/bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //bazel_disk_cache_cleaner + + - name: Build Darwin arm 64 binary + shell: bash + run: | + tools/bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_arm64 //bazel_disk_cache_cleaner + + - name: Build Darwin X86 64 binary + shell: bash + run: | + tools/bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 //bazel_disk_cache_cleaner + cp + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: | + Release ${{ github.ref }} + draft: false + prerelease: false + - uses: xresloader/upload-to-github-release@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + file: "*.md;*.zip;random-name-*.txt" + release_id: ${{ steps.create_release.outputs.id }} + overwrite: true + verbose: true \ No newline at end of file diff --git a/tools/bazel b/tools/bazel index 923ff1e..4e8a07d 100755 --- a/tools/bazel +++ b/tools/bazel @@ -4,11 +4,12 @@ set -eu -o pipefail platform="$(uname -s | tr '[:upper:]' '[:lower:]')" -os=${OSTYPE//[0-9.]/} +os=${OSTYPE%%-*} +os=${os//[0-9]/} arch="$(uname -m)" -if [[ ${arch} == "x86_64" ]]; then - arch="amd64" +if [[ ${arch} == "amd64" ]]; then + arch="x86_64" fi BAZEL_VERSION="6.4.0"