-
Notifications
You must be signed in to change notification settings - Fork 0
Enable Debian Build,Sign,Publish via GH Actions #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
endersonmaia
wants to merge
19
commits into
main
Choose a base branch
from
feature/ci-debian-build-multiple-archs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b50d94f
feat: add package scripts for Debian and Alpine
edubart c4c076b
feat: bump emulator, rootfs and tools
edubart 461ded2
feat: bump emulator (0.20.0), rootfs and tools (0.17.2)
endersonmaia 7ce62b8
feat(alpine): bump Alpine to 3.23, fix TARGET_ARCH for docker
endersonmaia 9a2f107
feat: fix build for Alpine
endersonmaia ecb6540
feat(debian): stick to ubuntu:noble
endersonmaia a079fe6
fixup! feat(alpine): bump Alpine to 3.23, fix TARGET_ARCH for docker
endersonmaia 9f47b56
docs: use cartesi.github.io/linux-packages
endersonmaia 1caaa4c
feat(debian): enable CI build with multiple architecture
endersonmaia 38d0e9d
feat(debian): use docker/buid-push-action
endersonmaia fc0b369
feat(debian): split sign step
endersonmaia 590cbe4
feat(debian): enable cache in CI
endersonmaia af33792
feat(debian): add packages-info target
endersonmaia b4e85d5
feat(debian): add test step to CI
endersonmaia c9b3e4c
feat(debian): test works without signed packages
endersonmaia ee77ff9
feat(debian): test works with select packages
endersonmaia 531d33e
feat(debian): add sign job
endersonmaia 42272b2
feat(debian): add publish job
endersonmaia 2842311
feat(build): limit PACKAGES_ALLARCH build only for amd64
endersonmaia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,205 @@ | ||
| name: Debian Packages | ||
| on: [push] | ||
|
|
||
| jobs: | ||
| debian-build: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - runner: ubuntu-24.04 | ||
| arch: amd64 | ||
| packages_allarch: "cartesi-machine-linux-image cartesi-machine-rootfs-image" | ||
| - runner: ubuntu-24.04-arm | ||
| arch: arm64 | ||
| packages_allarch: "" | ||
| - runner: ubuntu-24.04-riscv | ||
| arch: riscv64 | ||
| packages_allarch: "" | ||
|
|
||
| runs-on: ${{ matrix.runner }} | ||
| name: Debian Build | ||
| permissions: | ||
| packages: write | ||
| contents: read | ||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Setup up Docker Buildx | ||
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | ||
|
|
||
|
|
||
| - name: Make builder container image | ||
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 | ||
| with: | ||
| context: debian | ||
| file: debian/Dockerfile | ||
| platforms: linux/${{ matrix.arch }} | ||
| tags: cartesi/deb-builder-${{ matrix.arch }} | ||
| load: true | ||
| push: false | ||
| cache-from: type=gha,scope=${{ matrix.arch }} | ||
| cache-to: type=gha,scope=${{ matrix.arch }},mode=max | ||
|
|
||
| - name: Restore cached packages | ||
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | ||
| with: | ||
| path: cdn/apt | ||
| key: apt-packages-${{ matrix.arch }}-${{ github.sha }} | ||
| restore-keys: apt-packages-${{ matrix.arch }}- | ||
|
|
||
| - name: Build packages | ||
| working-directory: debian | ||
| run: | | ||
| make packages \ | ||
| TARGET_ARCH=${{ matrix.arch }} \ | ||
| PACKAGES_ALLARCH="${{ matrix.packages_allarch }}" | ||
|
|
||
| - name: Export builder container image | ||
| run: docker save cartesi/deb-builder-${{ matrix.arch }} | gzip > /tmp/deb-builder-${{ matrix.arch }}.tar.gz | ||
|
|
||
| - name: Upload builder container image | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| name: image-deb-builder-${{ matrix.arch }} | ||
| path: /tmp/deb-builder-${{ matrix.arch }}.tar.gz | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| name: artifacts-apt-${{ matrix.arch }} | ||
| path: cdn/apt | ||
|
|
||
| debian-test: | ||
| name: Debian Test | ||
| runs-on: ubuntu-24.04 | ||
| needs: debian-build | ||
| permissions: | ||
| packages: write | ||
| contents: read | ||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Download apt artifacts | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| pattern: artifacts-apt-* | ||
| path: cdn/apt/ | ||
| merge-multiple: true | ||
|
|
||
| - name: Download builder images | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| pattern: image-deb-builder-* | ||
| path: /tmp/images | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 | ||
|
|
||
| - name: Import builder images | ||
| run: find /tmp/images -name '*.tar.gz' | xargs -I {} docker image load --input {} | ||
|
|
||
| - name: Make index | ||
| working-directory: debian | ||
| run: make index | ||
|
|
||
| - name: Test | ||
| working-directory: debian | ||
| run: | | ||
| make test-packages TARGET_ARCH=amd64 | ||
| make test-packages TARGET_ARCH=arm64 | ||
| make test-packages TARGET_ARCH=riscv64 | ||
|
|
||
| debian-sign: | ||
| runs-on: ubuntu-24.04 | ||
| name: Debian Signing | ||
| needs: [ debian-build, debian-test ] | ||
| #FIXME: uncoment when have final signing key | ||
| #if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | ||
| environment: signing | ||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Download apt artifacts | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| pattern: artifacts-apt-* | ||
| path: cdn/apt/ | ||
| merge-multiple: true | ||
|
|
||
| - name: Download builder images | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| pattern: image-deb-builder-amd64 | ||
| path: /tmp/images | ||
|
|
||
| - name: Import builder images | ||
| run: find /tmp/images -name '*.tar.gz' | xargs -I {} docker image load --input {} | ||
|
|
||
| - name: Import GPG signing key | ||
| working-directory: debian | ||
| env: | ||
| DEB_KEY: ${{ secrets.DEB_KEY }} | ||
| run: | | ||
| mkdir -p key | ||
| chmod 700 key | ||
| echo "$DEB_KEY" | gpg --homedir "$(pwd)/key" --import | ||
|
|
||
| - name: Make index | ||
| working-directory: debian | ||
| run: make index | ||
|
|
||
| - name: Sign repository | ||
| working-directory: debian | ||
| run: make sign | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| name: signed-artifacts-apt | ||
| path: cdn | ||
|
|
||
| publish: | ||
| name: Debian Publish | ||
| needs: debian-sign | ||
| #FIXME: uncoment when process is validated | ||
| #if: startsWith(github.ref, 'refs/tags/v') | ||
| runs-on: ubuntu-24.04 | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| permissions: | ||
| pages: write | ||
| id-token: write | ||
| steps: | ||
| - name: Download signed archives | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: signed-artifacts-apt | ||
| path: _site/ | ||
|
|
||
| - name: Create GPG Public Key from variable | ||
| env: | ||
| DEB_PUB_KEY: ${{ vars.DEB_PUB_KEY }} | ||
| run: | | ||
| mkdir -p _site/apt/keys | ||
| echo "$DEB_PUB_KEY" > _site/apt/keys/cartesi-deb-key.gpg | ||
|
|
||
| - name: Setup Pages | ||
| uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v5.0.0 | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 | ||
|
|
||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| cdn | ||
| key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,12 @@ | ||
| # linux-packages | ||
| Cartesi Linux Packages Repository | ||
| # Cartesi Linux Packages | ||
|
|
||
| Cartesi Linux packages repository, containing packaging for: | ||
|
|
||
| - Debian 12 (Bookworm) - Host | ||
| - Ubuntu 24.04 LTS (Noble) - Guest | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also Host and Guest. For both Ubuntu and Debian. |
||
| - Alpine Linux 3.23 - Host and Guest | ||
|
|
||
| Debian/Ubuntu packages are available in [debian](debian) subdirectory. | ||
| Alpine packages are available in [alpine](alpine) subdirectory. | ||
|
|
||
| You can find instructions on the sub directories. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to create a |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ARG BASE_IMAGE=alpine | ||
| FROM ${BASE_IMAGE} | ||
|
|
||
| # Install build essential | ||
| RUN apk update && \ | ||
| apk upgrade && \ | ||
| apk add alpine-sdk | ||
|
|
||
| # List local apk repository | ||
| RUN echo /root/packages/work >> /etc/apk/repositories && \ | ||
| adduser -D builder | ||
|
|
||
| WORKDIR /work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| # List of packages to compile for any architecture | ||
| PACKAGES_ANYARCH=\ | ||
| cartesi-machine-linux-image \ | ||
| cartesi-machine-rootfs-image \ | ||
| cartesi-machine-emulator \ | ||
| xgenext2fs | ||
|
|
||
| # List of packages to compile for riscv64 | ||
| PACKAGES_RISCV64=\ | ||
| cartesi-machine-guest-linux-headers \ | ||
| cartesi-machine-guest-tools | ||
|
|
||
| # Target architecture to compile packages | ||
| TARGET_ARCH?=$(shell uname -m) | ||
|
|
||
| # Docker platform architecture (maps uname -m names to Docker platform names) | ||
| DOCKER_ARCH_x86_64=amd64 | ||
| DOCKER_ARCH_aarch64=arm64 | ||
| DOCKER_ARCH_riscv64=riscv64 | ||
| DOCKER_ARCH=$(DOCKER_ARCH_$(TARGET_ARCH)) | ||
|
|
||
| # Docker base image used for building packages | ||
| BASE_IMAGE=alpine:3.23 | ||
| IMAGE=cartesi/apk-builder-$(DOCKER_ARCH) | ||
|
|
||
| # Repository path to save built packages | ||
| REPO_PATH=$(abspath ../cdn)/apk | ||
| REPO_NAME=stable | ||
| KEY_NAME=cartesi-apk-key | ||
|
|
||
| # Package list to build | ||
| PACKAGES=$(PACKAGES_ANYARCH) | ||
| ifeq ($(TARGET_ARCH),riscv64) | ||
| PACKAGES+=$(PACKAGES_RISCV64) | ||
| endif | ||
|
|
||
| all: ## Generate a key (if needed) and build all packages | ||
| @$(MAKE) --no-print-directory image | ||
| @$(MAKE) --no-print-directory key | ||
| @$(MAKE) --no-print-directory packages-all | ||
|
|
||
| packages-all: ## Build packages for all architectures (x86_64/aarch64/riscv64) | ||
| @$(MAKE) --no-print-directory image TARGET_ARCH=x86_64 | ||
| @$(MAKE) --no-print-directory packages TARGET_ARCH=x86_64 | ||
| @$(MAKE) --no-print-directory image TARGET_ARCH=aarch64 | ||
| @$(MAKE) --no-print-directory packages TARGET_ARCH=aarch64 | ||
| @$(MAKE) --no-print-directory image TARGET_ARCH=riscv64 | ||
| @$(MAKE) --no-print-directory packages TARGET_ARCH=riscv64 | ||
|
|
||
| packages: $(patsubst %,%.apk,$(PACKAGES)) ## Build packages for given TARGET_ARCH | ||
|
|
||
| %.apk: ## Build a package for given TARGET_ARCH | ||
| @$(MAKE) --no-print-directory exec COMMAND="\ | ||
| cd $* && \ | ||
| export SOURCE_DATE_EPOCH=\\\`stat -c %Y APKBUILD\\\` && \ | ||
| abuild -rF && \ | ||
| chown -R $(shell id -u):$(shell id -g) /root/packages/work" | ||
|
|
||
| key: ## Generate package signature key | ||
| echo "NOTICE: Generating new key!" | ||
| @mkdir -p $(REPO_PATH)/keys key | ||
| docker run --platform=linux/$(DOCKER_ARCH) \ | ||
| --volume ./key:/root/.abuild \ | ||
| --volume $(REPO_PATH):/apk \ | ||
| --rm $(IMAGE) \ | ||
| ash -c "\ | ||
| abuild-keygen -n && \ | ||
| mv /root/.abuild/*.rsa.pub /root/.abuild/$(KEY_NAME).rsa.pub && \ | ||
| mv /root/.abuild/*.rsa /root/.abuild/$(KEY_NAME).rsa && \ | ||
| echo 'PACKAGER_PRIVKEY=/root/.abuild/$(KEY_NAME).rsa' > /root/.abuild/abuild.conf && \ | ||
| cp /root/.abuild/$(KEY_NAME).rsa.pub /apk/keys/$(KEY_NAME).rsa.pub && \ | ||
| chown -R $(shell id -u):$(shell id -g) /root/.abuild /apk/keys" | ||
|
|
||
| shell: ## Spawn an image shell for given TARGET_ARCH | ||
| @$(MAKE) --no-print-directory exec DOCKER_FLAGS="-it" COMMAND="ash" | ||
|
|
||
| exec: ## Execute a COMMAND inside an image for given TARGET_ARCH | ||
| docker run --platform=linux/$(DOCKER_ARCH) \ | ||
| --volume ./key:/key \ | ||
| --volume $(REPO_PATH)/$(REPO_NAME):/root/packages/work \ | ||
| --volume .:/work \ | ||
| --workdir /work \ | ||
| $(DOCKER_FLAGS) --rm $(IMAGE) \ | ||
| ash -c "\ | ||
| cp /key/*.rsa.pub /etc/apk/keys/ && \ | ||
| cp -a /key /root/.abuild && \ | ||
| chown -R root:root /root/.abuild && \ | ||
| $(COMMAND)" | ||
|
|
||
| image: ## Build Docker image for building packages for given TARGET_ARCH | ||
| docker build --platform=linux/$(DOCKER_ARCH) \ | ||
| --build-arg=BASE_IMAGE=$(BASE_IMAGE) \ | ||
| --tag=$(IMAGE) \ | ||
| --progress=plain \ | ||
| --file Dockerfile . | ||
|
|
||
| test: ## Test built packages for all architectures (x86_64/aarch64/riscv64) | ||
| @$(MAKE) --no-print-directory test-packages TARGET_ARCH=x86_64 | ||
| @$(MAKE) --no-print-directory test-packages TARGET_ARCH=aarch64 | ||
| @$(MAKE) --no-print-directory test-packages TARGET_ARCH=riscv64 | ||
|
|
||
| ifeq ($(TARGET_ARCH),riscv64) | ||
| test-packages: | ||
| @$(MAKE) --no-print-directory exec COMMAND="\ | ||
| apk add $(PACKAGES) && \ | ||
| rollup --help && \ | ||
| cartesi-machine --final-hash" | ||
| else | ||
| test-packages: ## Test built packages for given TARGET_ARCH | ||
| @$(MAKE) --no-print-directory exec COMMAND="\ | ||
| apk add $(PACKAGES) && \ | ||
| cartesi-machine --final-hash" | ||
| endif | ||
|
|
||
| distclean: ## Remove everything from APK repository directory | ||
| rm -rf $(REPO_PATH)/$(REPO_NAME) | ||
|
|
||
| help: ## Show this help | ||
| @sed \ | ||
| -e '/^[a-zA-Z0-9_\-]*:.*##/!d' \ | ||
| -e 's/:.*##\s*/:/' \ | ||
| -e 's/^\(.\+\):\(.*\)/$(shell tput setaf 6)\1$(shell tput sgr0):\2/' \ | ||
| $(MAKEFILE_LIST) | column -c2 -t -s : | ||
|
|
||
| .PHONY: all packages-all packages shell exec image test test-packages distclean help |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to Debian 13 Trixie here.