Skip to content

Commit

Permalink
Add version to artifact filename
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelo Politzer committed Nov 17, 2022
1 parent 1d7714e commit dad699d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ jobs:
with:
submodules: recursive
token: ${{ secrets.CI_TOKEN }}
fetch-depth: 0 # fetch tags

- name: Copy default Buildroot and Busybox config
run: make init-config

- name: Resolve rootfs filename from Makefile
run: echo ROOTFS_FILENAME="$(make rootfs-filename)" >> $GITHUB_ENV

- name: Setup primary site
run: sed -i -e 's#BR2_PRIMARY_SITE=""#BR2_PRIMARY_SITE="http://172.17.0.1:8080"#' cartesi-buildroot-config

Expand Down Expand Up @@ -75,6 +79,7 @@ jobs:
build-args: |
TOOLCHAIN_REPOSITORY=${{ secrets.DOCKER_ORGANIZATION }}/toolchain
TOOLCHAIN_VERSION=${{ env.TOOLCHAIN_VERSION }}
ROOTFS_FILENAME=${{ env.ROOTFS_FILENAME }}
cache-from: type=gha,mode=max,scope=regular
cache-to: type=gha,scope=regular

Expand All @@ -88,7 +93,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
with:
prerelease: true
files: rootfs.ext2
files: rootfs-*.ext2
env:
GITHUB_TOKEN: ${{ secrets.CI_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootfs.ext2
rootfs-*.ext2
cartesi-buildroot-config
cartesi-busybox-fragment
skel/etc/os-release
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ARG RISCV_ARCH=rv64g
ARG RISCV_ABI=lp64d
ENV RISCV_ARCH $RISCV_ARCH
ENV RISCV_ABI $RISCV_ABI
ARG ROOTFS_FILENAME=rootfs.ext2

ENV RISCV "$BASE/riscv64-cartesi-linux-gnu"
ENV PATH "$RISCV/bin:${OLDPATH}"
Expand Down Expand Up @@ -62,8 +63,8 @@ RUN \
cp local.mk work/local.mk && \
make BR2_EXTERNAL=$BUILD_BASE/buildroot/external O=work olddefconfig && \
make -C work && \
cp work/images/rootfs.ext2 $BUILD_BASE/artifacts && \
truncate -s %4096 $BUILD_BASE/artifacts/rootfs.ext2
cp work/images/rootfs.ext2 $BUILD_BASE/artifacts/$ROOTFS_FILENAME && \
truncate -s %4096 $BUILD_BASE/artifacts/$ROOTFS_FILENAME

USER root

Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ BUSYBOX_CONFIG ?= configs/default-busybox-fragment
RISCV_ARCH ?= rv64g
RISCV_ABI ?= lp64d

ROOTFS_VERSION ?= $(shell git describe --dirty --tags)
ROOTFS_FILENAME ?= rootfs-$(ROOTFS_VERSION).ext2

CONTAINER_BASE := /opt/cartesi/rootfs

IMG_REPO ?= cartesi/rootfs
IMG ?= $(IMG_REPO):$(TAG)
BASE:=/opt/riscv
ART:=$(BASE)/rootfs/artifacts/rootfs.ext2
ART:=$(BASE)/rootfs/artifacts/$(ROOTFS_FILENAME)

ifneq ($(TOOLCHAIN_DOCKER_REPOSITORY),)
BUILD_ARGS := --build-arg TOOLCHAIN_REPOSITORY=$(TOOLCHAIN_DOCKER_REPOSITORY)
Expand All @@ -39,6 +42,7 @@ endif

BUILD_ARGS += --build-arg RISCV_ARCH=$(RISCV_ARCH)
BUILD_ARGS += --build-arg RISCV_ABI=$(RISCV_ABI)
BUILD_ARGS += --build-arg ROOTFS_FILENAME=$(ROOTFS_FILENAME)

.NOTPARALLEL: all
all: build copy
Expand Down Expand Up @@ -83,7 +87,7 @@ clean-config:
rm -f ./cartesi-buildroot-config ./cartesi-busybox-fragment

clean: clean-config
rm -f rootfs.ext2
rm -f $(ROOTFS_FILENAME)

copy:
ID=`docker create $(IMG)` && docker cp $$ID:$(ART) . && docker rm -v $$ID
Expand All @@ -97,7 +101,7 @@ echo-os-release:
HOME_URL="https://cartesi.io/"
SUPPORT_URL="https://docs.cartesi.io/"
BUG_REPORT_URL="https://docs.cartesi.io/#qa"
VERSION_ID="$(shell git describe --long --dirty --tags)"
VERSION_ID="$(ROOTFS_VERSION)"

skel/etc/os-release:
$(MAKE) --no-print-directory echo-os-release > $@
Expand All @@ -107,3 +111,6 @@ copy-br2-dl-cache:
ID=`docker create $(IMG)` && \
docker cp $$ID:/opt/riscv/rootfs/buildroot/dl $(CACHE_DIR) && \
docker rm -v $$ID

rootfs-filename:
@echo $(ROOTFS_FILENAME)

0 comments on commit dad699d

Please sign in to comment.