droidian rootfs-builder #791
This file contains 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
name: droidian rootfs-builder | |
on: | |
workflow_dispatch: | |
push: | |
schedule: | |
- cron: "59 23 * * *" | |
jobs: | |
once: | |
runs-on: ubuntu-20.04 | |
name: Generate matrix | |
outputs: | |
matrix: ${{ steps.gen-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Generate matrix | |
id: gen-matrix | |
run: | | |
JOBS="$(./generate_device_recipe.py --matrix)" | |
echo "matrix=${JOBS}" >> $GITHUB_OUTPUT | |
build: | |
runs-on: ubuntu-20.04 | |
needs: once | |
strategy: | |
fail-fast: true | |
matrix: | |
config: ${{ fromJson(needs.once.outputs.matrix) }} | |
name: ${{ matrix.config.job_name }} | |
steps: | |
- name: Get current date | |
run: echo "current_date=$(date +'%Y%m%d')" >> $GITHUB_ENV | |
- name: Set suffix | |
run: echo "release_suffix=_${{ env.current_date }}" >> $GITHUB_ENV | |
- name: Set nightly version | |
if: startsWith(github.ref, 'refs/tags/droidian') != true | |
run: echo "DROIDIAN_VERSION=next" >> $GITHUB_ENV | |
- name: Set version | |
if: startsWith(github.ref, 'refs/tags/droidian') == true | |
run: echo "DROIDIAN_VERSION=$(echo ${{ github.ref }} | rev | cut -d'/' -f1 | rev)" >> $GITHUB_ENV | |
- name: Set identifier | |
run: echo "DROIDIAN_IDENTIFIER=${{ matrix.config.product }}-${{ matrix.config.arch }}-${{ matrix.config.edition }}-${{ matrix.config.variant }}-${{ matrix.config.apilevel }}" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
lfs: 'true' | |
submodules: 'recursive' | |
- name: Checkout submodules | |
run: git submodule update --init --recursive | |
- name: QEMU set-up | |
uses: docker/setup-qemu-action@v3 | |
- name: Create build dir | |
run: mkdir -p /tmp/buildd-results | |
- name: Pull container | |
run: docker pull quay.io/droidian/rootfs-builder:next-amd64 | |
- name: Start Container | |
run: echo CONTAINER_HASH=$(docker run --detach --privileged -v /tmp/buildd-results:/buildd/out -v /dev:/host-dev -v /sys/fs/cgroup:/sys/fs/cgroup -v ${PWD}:/buildd/sources --security-opt seccomp:unconfined quay.io/droidian/rootfs-builder:next-amd64 /sbin/init) >> $GITHUB_ENV | |
- name: Build rootfs | |
run: | | |
docker exec $CONTAINER_HASH /bin/sh -c 'cd /buildd/sources; DROIDIAN_VERSION="${{ env.DROIDIAN_VERSION }}" ./generate_device_recipe.py ${{ matrix.config.product }} ${{ matrix.config.arch }} ${{ matrix.config.edition }} ${{ matrix.config.variant }} ${{ matrix.config.apilevel }} && debos --disable-fakemachine generated/droidian.yaml' | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: droidian-out-${{ matrix.config.product }}-${{ matrix.config.arch }}-${{ matrix.config.edition }}-${{ matrix.config.variant }}-${{ matrix.config.apilevel }} | |
path: out/* | |
if-no-files-found: error | |
retention-days: 1 | |
prepare: | |
runs-on: ubuntu-20.04 | |
name: Create GitHub release | |
needs: build | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }}${{ steps.create_nightly.outputs.upload_url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Free up some storage | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: true | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
swap-storage: true | |
- name: Nightly tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: startsWith(github.ref, 'refs/tags/droidian') != true | |
run: | | |
gh release delete nightly --yes | true | |
git push --delete origin refs/tags/nightly || true | |
gh release create nightly | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: droidian-out | |
- name: Create SHA256SUMS | |
run: | | |
cd droidian-out | |
for x in droidian-out-*; do | |
cd $x | |
sha256sum * >> ../SHA256SUMS | |
cd .. | |
done | |
- name: Create stable release (drafted) | |
id: create_release | |
if: startsWith(github.ref, 'refs/tags/droidian') | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: droidian-out/SHA256SUMS | |
tag_name: ${{ github.ref }} | |
draft: true | |
prerelease: false | |
- name: Create nightly release | |
id: create_nightly | |
if: startsWith(github.ref, 'refs/tags/droidian') != true | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: droidian-out/SHA256SUMS | |
tag_name: nightly | |
draft: false | |
prerelease: true | |
publish: | |
runs-on: ubuntu-20.04 | |
needs: [once, prepare] | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }}${{ steps.create_nightly.outputs.upload_url }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: ${{ fromJson(needs.once.outputs.matrix) }} | |
name: Publish ${{ matrix.config.job_name }} | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: droidian-out-${{ matrix.config.product }}-${{ matrix.config.arch }}-${{ matrix.config.edition }}-${{ matrix.config.variant }}-${{ matrix.config.apilevel }} | |
path: droidian-out | |
- name: Create stable release (drafted) | |
id: create_release | |
if: startsWith(github.ref, 'refs/tags/droidian') | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: droidian-out/* | |
tag_name: ${{ github.ref }} | |
draft: true | |
prerelease: false | |
- name: Create nightly release | |
id: create_nightly | |
if: startsWith(github.ref, 'refs/tags/droidian') != true | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: droidian-out/* | |
tag_name: nightly | |
draft: false | |
prerelease: true |