Skip to content

Build and release mainline #77

Build and release mainline

Build and release mainline #77

# Taken from https://github.com/mainsail-crew/armbian-builds/blob/d39a0ebc2d53446c32d1d5f936df2528ebd66de1/.github/workflows/BuildTrain.yml
name: Build and release mainline
on:
workflow_dispatch:
# on every monday at 3:30
schedule:
- cron: "30 3 * * 1"
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
id: ${{ steps.release.outputs.id }}
armbian_version: ${{ steps.armbian-version.outputs.version }}
ubuntu_version: ${{ steps.ubuntu-version.outputs.version }}
version: ${{ steps.version.outputs.version }}
tag_name: ${{ steps.time.outputs.time }}
steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
path: mellowfly-geminipi-armbian
- name: Get this commit sha
id: mfgp-version
run: |
VERSION=$(cd mellowfly-geminipi-armbian; git rev-parse --short HEAD)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Get armbian version
id: armbian-version
run: |
VERSION=$(cat ./mellowfly-geminipi-armbian/armbian-version.txt)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Get ubuntu version
id: ubuntu-version
run: |
VERSION=$(cat ./mellowfly-geminipi-armbian/ubuntu-version.txt)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Get time
id: time
uses: nanzm/get-time-action@v2.0
with:
format: "YYYYMMDD-HHmm"
- name: Print version
id: version
run: |
VERSION="${{ steps.armbian-version.outputs.version }}-${{ steps.mfgp-version.outputs.version }}-${{ steps.time.outputs.time }}"
VERSION=${VERSION#v}
VERSION=${VERSION/trunk./trunk-}
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Create empty release
id: release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.version.outputs.version }}
generate_release_notes: true
tag_name: ${{ steps.time.outputs.time }}
token: ${{ secrets.GITHUB_TOKEN }}
draft: true
build-armbian:
name: Armbian
needs: [release]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch: [current, edge]
steps:
- name: Get more space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 25600
swap-size-mb: 1024
remove-dotnet: "true"
remove-android: "true"
remove-codeql: "true"
remove-docker-images: "true"
remove-haskell: "true"
- name: Checkout this repository
uses: actions/checkout@v4
with:
path: mellowfly-geminipi-armbian
- name: Checkout armbian Repository
uses: actions/checkout@v4
with:
fetch-depth: 1
repository: armbian/build
ref: ${{ needs.release.outputs.armbian_version }}
path: armbian
- name: Apply patches
run: |
cd armbian/
git apply ../mellowfly-geminipi-armbian/patches/*.patch
- name: Build Armbian
run: |
cd armbian/
echo "${{ needs.release.outputs.version }}" | tee VERSION
./compile.sh BOARD=mellowflygeminipi \
BRANCH=${{ matrix.branch }} \
RELEASE=${{ needs.release.outputs.ubuntu_version }} \
BUILD_MINIMAL=no \
BUILD_DESKTOP=no \
KERNEL_CONFIGURE=no \
INSTALL_HEADERS=yes \
BOOTFS_TYPE=fat
- name: Retrieve image name
id: image-name
run: |
WORKSPACE=$(echo ${{ github.workspace }})
cd $WORKSPACE/armbian/output/images/
IMAGE_NAME=$(ls -1 *.img | head -n1)
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
- name: Compressing Image
run: |
WORKSPACE=$(echo ${{ github.workspace }})
cd $WORKSPACE/armbian/output/images/
xz -efkvz "${{ steps.image-name.outputs.image_name }}" || true
- name: Calculating checksums
run: |
WORKSPACE=$(echo ${{ github.workspace }})
cd $WORKSPACE/armbian/output/images/
sha256sum "${{ steps.image-name.outputs.image_name }}" > "${{ steps.image-name.outputs.image_name }}.sha256"
sha256sum "${{ steps.image-name.outputs.image_name }}.xz" > "${{ steps.image-name.outputs.image_name }}.xz.sha256"
- name: Upload Image to Release
if: needs.release.outputs.id != ''
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ./armbian/output/images/*.img.xz
draft: true
- name: Upload Checksum to Release
if: needs.release.outputs.id != ''
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ./armbian/output/images/*.sha256
draft: true
- name: Upload Config to Release
if: needs.release.outputs.id != ''
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ./armbian/output/images/*.txt
draft: true
- name: Create Debian Package Archive
if: needs.release.outputs.id != ''
run: |
WORKSPACE=$(echo ${{ github.workspace }})
cd $WORKSPACE/armbian/output/debs/
tar vcfJ "kernel_packages_${{ matrix.branch }}_${{ needs.release.outputs.version }}.tar.xz" *.deb
- name: Upload Debian Packages to Release
if: needs.release.outputs.id != ''
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ./armbian/output/debs/kernel_packages_${{ matrix.branch }}_${{ needs.release.outputs.version }}.tar.xz
draft: true
finish:
name: Publish Release
needs: [release, build-armbian]
runs-on: ubuntu-latest
steps:
- name: Publish Release
uses: StuYarrow/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
id: ${{ needs.release.outputs.id }}
- name: Start MainsailOS Build
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.MAINSAIL_REPO_DISPATCH_TOKEN }}
repository: reemo3dp/mellowfly-geminipi-mainsailos
event-type: new-mellowfly-geminipi-armbian-release
client-payload: '{"release_id": "${{ needs.release.outputs.id }}"}'
- name: Github Releases To Discord
uses: reemo3dp/github-releases-to-discord@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_id: ${{ needs.release.outputs.id }}
webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}
color: "2105893"
username: "Release Changelog"
avatar_url: "https://cdn.discordapp.com/avatars/487431320314576937/bd64361e4ba6313d561d54e78c9e7171.png"
footer_title: "Changelog"
footer_icon_url: "https://cdn.discordapp.com/avatars/487431320314576937/bd64361e4ba6313d561d54e78c9e7171.png"
footer_timestamp: true
cleanup:
name: Cleanup
needs: [release, build-armbian]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Delete drafts
uses: hugo19941994/delete-draft-releases@v1.0.1
with:
threshold: 2d
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}