Skip to content

Commit

Permalink
Add automatic compilation for production image.
Browse files Browse the repository at this point in the history
  • Loading branch information
is-qian committed Jul 5, 2024
1 parent be664c0 commit 5996750
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 13 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Build all images

on:
create:
tags:
- '*'

workflow_dispatch:
inputs:
tag_name:
description: 'Tag name'
required: true
default: 'v1.0.0'
type: string

jobs:
Build-all-images:
runs-on: ubuntu-latest
steps:
- name: Check tag
id: check_tag
run: |
if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
elif [[ ${{ github.event_name }} == 'create' ]]; then
echo "TAG_NAME=${{ github.ref }}" >> $GITHUB_ENV
fi
- name: Creat release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}
draft: false

- name: build raspberrypi image
uses: benc-uk/workflow-dispatch@v1.1
with:
workflow: Build pi-gen image
token: ${{ secrets.GITHUB_TOKEN }}
inputs: >-
{
"dev_name": "raspberrypi",
"pi-gen-version": "arm64",
"enable-ssh": "1",
"stage-list": "stage0 stage1 stage2 stage3 stage4",
"wpa-country" : "CN",
"keyboard-keymap": "us",
"disable-first-boot-user-rename": "0",
"username": "pi",
"password": "raspberry",
"release_url": "${{ steps.create_release.outputs.upload_url }}"
}
- name: build reComputer-R100x image
uses: benc-uk/workflow-dispatch@v1.1
with:
workflow: Build pi-gen image
token: ${{ secrets.GITHUB_TOKEN }}
inputs: >-
{
"dev_name": "reComputer-R100x",
"pi-gen-version": "arm64",
"enable-ssh": "1",
"stage-list": "stage0 stage1 stage2 stage3 stage4 stage4a",
"wpa-country" : "CN",
"keyboard-keymap": "us",
"disable-first-boot-user-rename": "1",
"username": "recomputer",
"password": "12345678",
"release_url": "${{ steps.create_release.outputs.upload_url }}"
}
- name: build reTerminal image
uses: benc-uk/workflow-dispatch@v1.1
with:
workflow: Build pi-gen image
token: ${{ secrets.GITHUB_TOKEN }}
inputs: >-
{
"dev_name": "reTerminal",
"pi-gen-version": "arm64",
"enable-ssh": "1",
"stage-list": "stage0 stage1 stage2 stage3 stage4 stage4a",
"wpa-country" : "CN",
"keyboard-keymap": "us",
"disable-first-boot-user-rename": "0",
"username": "pi",
"password": "raspberry",
"release_url": "${{ steps.create_release.outputs.upload_url }}"
}
- name: build reTerminal-plus image
uses: benc-uk/workflow-dispatch@v1.1
with:
workflow: Build pi-gen image
token: ${{ secrets.GITHUB_TOKEN }}
inputs: >-
{
"dev_name": "reTerminal-plus",
"pi-gen-version": "arm64",
"enable-ssh": "1",
"stage-list": "stage0 stage1 stage2 stage3 stage4 stage4a",
"wpa-country" : "CN",
"keyboard-keymap": "us",
"disable-first-boot-user-rename": "1",
"username": "pi",
"password": "raspberry",
"release_url": "${{ steps.create_release.outputs.upload_url }}"
}
49 changes: 36 additions & 13 deletions .github/workflows/pi-gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,10 @@ on:
required: true
default: 'raspberry'
type: string
verbose-output:
description: 'Enable verbose output'
required: true
default: 'false'
type: choice
options:
- true
- false
release_url:
description: 'Release URL'
default: ""
type: string

env:
EXPORT_LAST_STAGE_ONLY: true
Expand Down Expand Up @@ -123,6 +119,14 @@ jobs:
chmod +x stage4a/prerun.sh
chmod +x stage4a/00-dtoverlays/*.sh
- name: Determing whether to upload to release
run: |
if [ "${{ inputs.release_url }}" == "" ]; then
echo "UPLOAD_TO_RELEASE=true" >> $GITHUB_ENV
else
echo "UPLOAD_TO_RELEASE=false" >> $GITHUB_ENV
fi
- name: Build ${{ inputs.dev_name }} with stagelists
uses: usimd/pi-gen-action@v1
id: build
Expand All @@ -136,7 +140,7 @@ jobs:
stage-list: ${{ inputs.stage-list }}
pi-gen-dir: ${{ env.PI_GEN_DIR }}
export-last-stage-only: ${{ env.EXPORT_LAST_STAGE_ONLY }}
verbose-output: ${{ inputs.verbose-output }}
verbose-output: ${{ env.UPLOAD_TO_RELEASE }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
hostname: ${{ inputs.dev_name }}
Expand All @@ -148,19 +152,38 @@ jobs:
name: Raspbian-${{ inputs.dev_name }}-${{ inputs.pi-gen-version }}
path: ${{ steps.build.outputs.image-path }}

- name: get Artifact download URL
- name: Uploading ${{ inputs.dev_name }} image to release
id: release-step
if: ${{ env.UPLOAD_TO_RELEASE }} == "false"
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.release_url }}
asset_path: ${{ steps.build.outputs.image-path }}
asset_name: Raspbian-${{ inputs.dev_name }}-${{ inputs.pi-gen-version }}
asset_content_type: application/zip

- name: Get realease url
if: ${{ env.UPLOAD_TO_RELEASE }} == "false"
run: |
echo "ARTIFACT_URL=${{ steps.artifact-upload-step.outputs.artifact-url }}" >> $GITHUB_ENV
echo "RELEASE_URL=${{ steps.release-step.outputs.browser_download_url }}" >> $GITHUB_ENV
- name: Setup Python
uses: actions/setup-python@v2

- name: update README.md
if: ${{ env.UPLOAD_TO_RELEASE }} == "false"
run: |
echo "## ${{ steps.build.outputs.image-path }} image ${{ inputs.dev_name }}-${{ inputs.pi-gen-version }} ${{ env.ARTIFACT_URL }}"
python3 update_readme.py ${{ inputs.dev_name }}-${{ inputs.pi-gen-version }} ${{ inputs.username }} ${{ inputs.password }} ${{ inputs.enable-ssh }} "${{ inputs.stage-list }}" ${{ env.ARTIFACT_URL }}
git config --local user.name "GitHub Action"
git config --local user.email "action@github.com"
git checkout main
git pull
echo "## ${{ steps.build.outputs.image-path }} image ${{ inputs.dev_name }}-${{ inputs.pi-gen-version }} ${{ env.RELEASE_URL }}"
python3 update_readme.py ${{ inputs.dev_name }}-${{ inputs.pi-gen-version }} ${{ inputs.username }} ${{ inputs.password }} ${{ inputs.enable-ssh }} "${{ inputs.stage-list }}" ${{ env.RELEASE_URL }}
- name: Commit and push changes
if: ${{ env.UPLOAD_TO_RELEASE }} == "false"
run: |
git config --local user.name "GitHub Action"
git config --local user.email "action@github.com"
Expand Down

0 comments on commit 5996750

Please sign in to comment.