droidian rootfs-builder #281
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@v2 | |
- name: Generate matrix | |
id: gen-matrix | |
run: | | |
JOBS="$(./generate_device_recipe.py --matrix)" | |
echo ::set-output name=matrix::${JOBS} | |
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=nightly" >> $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@v2 | |
with: | |
lfs: 'true' | |
submodules: 'recursive' | |
- name: Checkout submodules | |
run: git submodule update --init --recursive | |
- name: QEMU set-up | |
uses: docker/setup-qemu-action@v1 | |
- name: Create build dir | |
run: mkdir -p /tmp/buildd-results | |
- name: Pull container | |
run: docker pull quay.io/droidian/rootfs-builder:bookworm-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:bookworm-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@v3 | |
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: Delete old nightly release | |
uses: dev-drprasad/delete-tag-and-release@v0.2.1 | |
if: startsWith(github.ref, 'refs/tags/droidian') != true | |
with: | |
delete_release: true # default: false | |
tag_name: nightly # tag name to delete | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Tag snapshot | |
if: startsWith(github.ref, 'refs/tags/droidian') != true | |
uses: tvdias/github-tagger@v0.0.1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
tag: nightly | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
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@v1 | |
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@v1 | |
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@v3 | |
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@v1 | |
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@v1 | |
with: | |
files: droidian-out/* | |
tag_name: nightly | |
draft: false | |
prerelease: true |