Skip to content

Commit

Permalink
Change image to publish on tag (not push to master) (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordy25519 authored Dec 11, 2024
1 parent 15c84d0 commit 54c1ee6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ on:
jobs:
format-build-test:
runs-on: ubicloud
timeout-minutes: 45
timeout-minutes: 15
steps:
- name: Check out
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Config rust toolchain
run: |
rustup update stable && rustup default stable
rustup component add rustfmt
rustup show active-toolchain
rustup install 1.76.0-x86_64-unknown-linux-gnu
- name: Format
run: cargo fmt --all -- --check
- name: install libdrift_ffi_sys
run: |
curl -L https://github.com/user-attachments/files/17849111/libdrift_ffi_sys.so.zip > ffi.zip && unzip ffi.zip
sudo cp libdrift_ffi_sys.so /usr/lib/
curl -L https://github.com/drift-labs/drift-ffi-sys/releases/download/v2.103.0/libdrift_ffi_sys.so.zip > ffi.zip && unzip ffi.zip
sudo cp libdrift_ffi_sys.so /lib/
- uses: ubicloud/rust-cache@v2
with:
path: |
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: Release

on:
push:
branches:
- "master"
tags:
- 'v*.*.*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
Expand All @@ -18,13 +19,23 @@ jobs:
timeout-minutes: 45
steps:
- name: Check out
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build image
run: |
VERSION_TAG=$(grep -Po -m1 '\d.\d.\d' Cargo.toml)
CARGO_VERSION=$(grep -Po '(?<=version = ")\d+\.\d+\.\d+' Cargo.toml)
TAG_VERSION=${GITHUB_REF#refs/tags/v}
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
echo "Version mismatch: Cargo.toml version ($CARGO_VERSION) doesn't match tag version ($TAG_VERSION)"
exit 1
fi
echo "Version $CARGO_VERSION matches tag"
docker build -f Dockerfile .\
-t "${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA::6}"\
-t "${REGISTRY}/${IMAGE_NAME}:${VERSION_TAG}"\
-t "${REGISTRY}/${IMAGE_NAME}:${TAG_VERSION}"\
-t "${REGISTRY}/${IMAGE_NAME}:latest"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 54c1ee6

Please sign in to comment.