Skip to content

Commit

Permalink
Merge branch 'ci/macos-build'
Browse files Browse the repository at this point in the history
* ci/macos-build:
  Stick to pip3 for macos (some workers has python2 for just "pip")
  No need to clone submodules (there is no one)
  Compress macos binary in artifacts
  Remove copy-paste from CI workflows
  Add binary for macos into pre releases artifacts

Fixes: #4
  • Loading branch information
azat committed Dec 17, 2023
2 parents 4d62453 + 98e54b0 commit d94f0a3
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 109 deletions.
125 changes: 125 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
name: Build chdig

on:
workflow_call:
inputs: {}

jobs:
build-linux:
name: Build Linux
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
with:
# To fetch tags, but can this be improved using blobless checkout?
# [1]. But anyway right it is not important, and unlikely will be,
# since the repository is small.
#
# [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
fetch-depth: 0

# Workaround for https://github.com/actions/checkout/issues/882
- name: Fix tags for release
# will break on a lightweight tag
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Install dependencies
run: |
# Stick to the 0.23.0 due to issue with static linking on 0.24.0 [1].
# [1]: https://github.com/indygreg/PyOxidizer/issues/673
pip install PyOxidizer==0.23.0
# nfpm
curl -sS -Lo /tmp/nfpm.deb "https://github.com/goreleaser/nfpm/releases/download/v2.25.0/nfpm_amd64.deb"
sudo dpkg -i /tmp/nfpm.deb
- name: Build
run: |
set -x
# for building cityhash for clickhouse-rs
sudo apt-get install -y musl-tools
# gcc cannot do cross compile, and there is no musl-g++ in musl-tools
sudo ln -srf /usr/bin/clang /usr/bin/musl-g++
# musl for static binaries
rustup target add x86_64-unknown-linux-musl
make packages target=x86_64-unknown-linux-musl
for postfix in .x86_64.rpm -x86_64.pkg.tar.zst _amd64.deb; do
cp chdig*$postfix chdig-latest$postfix
done
- name: Check package
run: |
sudo dpkg -i *.deb
chdig --help
- name: Archive Linux packages
uses: actions/upload-artifact@v3
with:
name: linux-packages
path: |
*.deb
*.rpm
*.tar.*
build-macos-x86_64:
name: Build MacOS (x86_64)
# This is x86-64, M1 not for free
#
# NOTE: on macos-13 it cannot find proper SDK, with the following error:
#
# unable to find suitable Apple SDK supporting macosx11.1 or newer
runs-on: macos-12

steps:
- uses: actions/checkout@v3
with:
# To fetch tags, but can this be improved using blobless checkout?
# [1]. But anyway right it is not important, and unlikely will be,
# since the repository is small.
#
# [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
fetch-depth: 0

# Workaround for https://github.com/actions/checkout/issues/882
- name: Fix tags for release
# will break on a lightweight tag
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Worker info
run: |
# SDKs versions
ls -al /Library/Developer/CommandLineTools/SDKs/
- name: Install dependencies
run: |
# Stick to the 0.23.0 due to issue with static linking on 0.24.0 [1].
# [1]: https://github.com/indygreg/PyOxidizer/issues/673
pip3 install PyOxidizer==0.23.0
- name: Build
run: |
set -x
make deploy-binary
cp target/chdig chdig-macos-x86_64
gzip --keep chdig-macos-x86_64
- name: Check package
run: |
ls -al
./chdig-macos-x86_64 --help
- name: Archive MacOS packages
uses: actions/upload-artifact@v3
with:
name: macos-packages
path: |
chdig-macos-x86_64.gz
63 changes: 15 additions & 48 deletions .github/workflows/pre_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,30 @@ on:
- main

jobs:
pre-release:
name: Pre Release
build:
uses: ./.github/workflows/build.yml

publish-pre-release:
name: Publish Pre Release
runs-on: ubuntu-22.04

permissions:
contents: write

steps:
- uses: actions/checkout@v3
with:
submodules: true
# To fetch tags, but can this be improved using blobless checkout?
# [1]. But anyway right it is not important, and unlikely will be,
# since the repository is small.
#
# [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
fetch-depth: 0

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Install dependencies
run: |
# Stick to the 0.23.0 due to issue with static linking on 0.24.0 [1].
# [1]: https://github.com/indygreg/PyOxidizer/issues/673
pip install PyOxidizer==0.23.0
# nfpm
curl -sS -Lo /tmp/nfpm.deb "https://github.com/goreleaser/nfpm/releases/download/v2.25.0/nfpm_amd64.deb"
sudo dpkg -i /tmp/nfpm.deb
- name: Build
run: |
set -x
# for building cityhash for clickhouse-rs
sudo apt-get install -y musl-tools
# gcc cannot do cross compile, and there is no musl-g++ in musl-tools
sudo ln -srf /usr/bin/clang /usr/bin/musl-g++
# musl for static binaries
rustup target add x86_64-unknown-linux-musl
make packages target=x86_64-unknown-linux-musl
for postfix in .x86_64.rpm -x86_64.pkg.tar.zst _amd64.deb; do
cp chdig*$postfix chdig-latest$postfix
done
- name: Check package
run: |
sudo dpkg -i *.deb
chdig --help
needs:
- build

steps:
- name: Download artifacts
uses: actions/download-artifact@v3
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
automatic_release_tag: "latest"
title: "Development Build"
files: |
*.deb
*.rpm
*.tar.*
macos-packages/chdig-macos-x86_64.gz
linux-packages/*.deb
linux-packages/*.rpm
linux-packages/*.tar.*
76 changes: 15 additions & 61 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,74 +7,28 @@ on:
- "v*"

jobs:
release:
name: Release
build:
uses: ./.github/workflows/build.yml

publish-release:
name: Publish Release
runs-on: ubuntu-22.04

permissions:
contents: write

steps:
- uses: actions/checkout@v3
with:
submodules: true
# To fetch tags, but can this be improved using blobless checkout?
# [1]. But anyway right it is not important, and unlikely will be,
# since the repository is small.
#
# [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
fetch-depth: 0

# Workaround for https://github.com/actions/checkout/issues/882
- name: Fix tags for release
# will break on a lightweight tag
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Install dependencies
run: |
# Stick to the 0.23.0 due to issue with static linking on 0.24.0 [1].
# [1]: https://github.com/indygreg/PyOxidizer/issues/673
pip install PyOxidizer==0.23.0
# nfpm
curl -sS -Lo /tmp/nfpm.deb "https://github.com/goreleaser/nfpm/releases/download/v2.25.0/nfpm_amd64.deb"
sudo dpkg -i /tmp/nfpm.deb
- name: Build
run: |
set -x
# debug
git describe
git tag --sort="-v:refname"
# test
git describe | grep -x "$GITHUB_REF_NAME"
# for building cityhash for clickhouse-rs
sudo apt-get install -y musl-tools
# gcc cannot do cross compile, and there is no musl-g++ in musl-tools
sudo ln -srf /usr/bin/clang /usr/bin/musl-g++
# musl for static binaries
rustup target add x86_64-unknown-linux-musl
make packages target=x86_64-unknown-linux-musl
for postfix in .x86_64.rpm -x86_64.pkg.tar.zst _amd64.deb; do
cp chdig*$postfix chdig-latest$postfix
done
- name: Check package
run: |
sudo dpkg -i *.deb
chdig --help
chdig --version
# test
chdig --version | grep -x "chdig ${GITHUB_REF_NAME/v}"
needs:
- build

steps:
- name: Download artifacts
uses: actions/download-artifact@v3
- uses: "marvinpinto/action-automatic-releases@latest"
with:
prerelease: false
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
*.deb
*.rpm
*.tar.*
macos-packages/chdig-macos-x86_64.gz
linux-packages/*.deb
linux-packages/*.rpm
linux-packages/*.tar.*

0 comments on commit d94f0a3

Please sign in to comment.