Skip to content

Commit

Permalink
ci: release with compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
SalHe committed Jan 3, 2024
1 parent 29db860 commit 5c60394
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 23 deletions.
120 changes: 97 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,113 @@ name: release

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v*"

jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get the release version from the tag
if: env.VERSION == ''
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Show the version
run: |
echo "version is: $VERSION"
- name: Check that tag version and Cargo.toml version are the same
shell: bash
run: |
if ! grep -q "version = \"${VERSION:1}\"" Cargo.toml; then
echo "version does not match Cargo.toml" >&2
exit 1
fi
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create $VERSION --draft --verify-tag --title $VERSION
outputs:
version: ${{ env.VERSION }}

build:
name: Upload Release Asset
needs: ['create-release']
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Download Dependencies
run: ./scripts/download-dependency.sh
- name: Build project
run: |
cargo build --release
- name: Create Release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release
run: |
cp ./target/release/yasqlplus yasqlplus-linux-amd64
version="${{ needs.create-release.outputs.version }}"
gh release upload "$version" yasqlplus-linux-amd64
build-compatible:
needs: ['create-release']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Docker image
uses: docker/build-push-action@v2
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
context: .
file: ./scripts/ci-release.Dockerfile
push: false
tags: bysp:latest

- name: Run Docker container
run: |
docker run --volume "${PWD}/:/yasqlplus" --name bysp bysp:latest
docker cp bysp:/yasqlplus/target/release/yasqlplus ./yasqlplus-linux-compatible-x86_64
- name: Upload release
run: |
version="${{ needs.create-release.outputs.version }}"
gh release upload "$version" yasqlplus-linux-compatible-x86_64
build-compatible-aarch64:
needs: ['create-release']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: uraimo/run-on-arch-action@v2
name: Build aarch64
id: runcmd
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./target/release/yasqlplus
asset_name: yasqlplus-linux-amd64
asset_content_type: application/octet-stream
arch: aarch64
distro: ubuntu18.04
githubToken: ${{ github.token }}
setup: |
mkdir -p "${PWD}/artifacts"
# Mount the artifacts directory as /artifacts in the container
dockerRunArgs: |
--volume "${PWD}/artifacts:/artifacts"
--volume "${PWD}/:/yasqlplus"
run: |
# Add Docker's official GPG key:
apt-get update
apt-get install -y ca-certificates curl gnupg
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
docker build -t bysp:latest ./scripts/ci-release.Dockerfile
docker run --name bysp bysp:latest
docker cp bysp:/yasqlplus/target/release/yasqlplus /artifacts/yasqlplusyasqlplus-compatible-aarch64
- name: Upload release
run: |
version="${{ needs.create-release.outputs.version }}"
gh release upload "$version" yasqlplus-compatible-aarch64
27 changes: 27 additions & 0 deletions scripts/ci-release-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

cat >>/etc/ld.so.conf <<EOF
/usr/local/lib
/usr/local/lib64
/usr/lib64/clang-private
EOF

cat /etc/ld.so.conf

source /opt/rh/devtoolset-7/enable
source /opt/rh/llvm-toolset-7/enable
source "$HOME/.cargo/env"

ldconfig

./scripts/download-dependency.sh

mkdir yasdb
cd yasdb
wget "https://linked.yashandb.com/resource/yashandb-personal-23.1.1.100-linux-$(uname -m).tar.gz" --no-check-certificate -O yashandb-personal.tar.gz
tar xzf yashandb-personal.tar.gz
cd ..

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/yasdb/lib

cargo build --release
10 changes: 10 additions & 0 deletions scripts/ci-release.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM centos:centos7

RUN yum install -y wget git centos-release-scl centos-release-scl-rh
RUN yum install -y devtoolset-7-gcc devtoolset-7-gcc-g++ llvm-toolset-7 gcc g++
RUN sh -c "$(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs)" -- -y

COPY ./scripts ./scripts
RUN ./scripts/ci-release-build.sh

ENTRYPOINT [ "bash" ]

0 comments on commit 5c60394

Please sign in to comment.