From 9c7019df53ce59306b65bcb1c9f4b31c23a99d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sun, 8 Jun 2025 15:54:24 +0200 Subject: [PATCH 1/4] Add a workflow to create a pre release automatically --- .github/workflows/kanso-cd.yml | 5 +++ .github/workflows/release.yml | 78 ++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/kanso-cd.yml b/.github/workflows/kanso-cd.yml index b4817c2..ab24cde 100644 --- a/.github/workflows/kanso-cd.yml +++ b/.github/workflows/kanso-cd.yml @@ -16,3 +16,8 @@ jobs: needs: kernel-build uses: ./.github/workflows/release-pine64_star64.yml secrets: inherit + + release-pine64_star64: + needs: release-pine64_star64 + uses: ./.github/workflows/release.yml + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b22bdf6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,78 @@ +name: Release +on: + workflow_call: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + + - name: Download artefacts + uses: actions/download-artifact@v4 + with: + path: artefacts + + - name: Collect publishable files + id: collect + shell: bash + run: | + mapfile -t FILES < <(find artefacts -type f \( \ + -iname '*.img' -o \ + -iname '*.elf' -o \ + -iname '*.bin' -o \ + -iname '*.tar.*' \)) + if [[ ${#FILES[@]} -eq 0 ]]; then + echo "::error::No artefacts to release"; exit 1 + fi + printf '%s\n' "${FILES[@]}" + { + echo 'list<>"$GITHUB_OUTPUT" + + - name: Bump tag + id: version + shell: bash + run: | + LAST=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0-DEV1") + IFS='.-' read -r MAJOR MINOR BUILD LABEL <<<"$LAST" + : "${LABEL:=DEV1}" + NEXT_BUILD=$((BUILD + 1)) + NEXT_TAG="${MAJOR}.${MINOR}.${NEXT_BUILD}-${LABEL}" + echo "last=$LAST" >>"$GITHUB_OUTPUT" + echo "next=$NEXT_TAG" >>"$GITHUB_OUTPUT" + + git config --global user.name "github-actions" + git config --global user.email "actions@github.com" + git tag "$NEXT_TAG" + git push origin "$NEXT_TAG" + + - name: Generate release notes + id: notes + shell: bash + run: | + RANGE="${{ steps.version.outputs.last }}..HEAD" + if ! git rev-parse "${{ steps.version.outputs.last }}" &>/dev/null; then + RANGE="HEAD" + fi + LOG=$(git log $RANGE --pretty=format:"- %s (%h)" --no-merges \ + | grep -vE 'Merge pull request' || true) + printf 'notes<>"$GITHUB_OUTPUT" + + - name: Publish GitHub pre-release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.version.outputs.next }} + name: "Nightly ${{ steps.version.outputs.next }}" + prerelease: true + body: | + **Automated pre-release build** + + Changes since `${{ steps.version.outputs.last }}`: + + ${{ steps.notes.outputs.notes }} + files: ${{ steps.collect.outputs.list }} From 88abb30df3be7df7c8deee47d48aff7b8c6c16dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sun, 8 Jun 2025 15:57:21 +0200 Subject: [PATCH 2/4] Append full version to release artifacts --- .github/workflows/release.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b22bdf6..eefb74f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,6 +51,35 @@ jobs: git tag "$NEXT_TAG" git push origin "$NEXT_TAG" + - name: Append version to filenames + id: renamed + shell: bash + run: | + VERSION="${{ steps.version.outputs.next }}" + mkdir renamed + NEWFILES=() + while IFS= read -r file; do + base=$(basename "$file") + dir=$(dirname "$file") # not used, but kept for clarity + ext="${base##*.}" + stem="${base%.*}" + # handle files without extension + if [[ "$base" == "$ext" ]]; then + new="renamed/${stem}_${VERSION}" + else + new="renamed/${stem}_${VERSION}.${ext}" + fi + cp "$file" "$new" + NEWFILES+=("$new") + done <<< "${{ steps.collect.outputs.list }}" + + printf '%s\n' "${NEWFILES[@]}" + { + echo 'list<>"$GITHUB_OUTPUT" + - name: Generate release notes id: notes shell: bash From 1f1039da458936fea9f08ea25cf9638f1be02102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sun, 8 Jun 2025 15:58:00 +0200 Subject: [PATCH 3/4] Fix CD --- .github/workflows/kanso-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/kanso-cd.yml b/.github/workflows/kanso-cd.yml index ab24cde..1f1dde4 100644 --- a/.github/workflows/kanso-cd.yml +++ b/.github/workflows/kanso-cd.yml @@ -17,7 +17,7 @@ jobs: uses: ./.github/workflows/release-pine64_star64.yml secrets: inherit - release-pine64_star64: + release: needs: release-pine64_star64 uses: ./.github/workflows/release.yml secrets: inherit From 9e6e93f7016a96c6c4b2ecdd9c2c5d994391509b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sun, 8 Jun 2025 16:15:32 +0200 Subject: [PATCH 4/4] Change release pipeline --- .github/workflows/release.yml | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eefb74f..e6fc063 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,13 +20,12 @@ jobs: shell: bash run: | mapfile -t FILES < <(find artefacts -type f \( \ - -iname '*.img' -o \ - -iname '*.elf' -o \ - -iname '*.bin' -o \ - -iname '*.tar.*' \)) - if [[ ${#FILES[@]} -eq 0 ]]; then - echo "::error::No artefacts to release"; exit 1 - fi + -iname 'kanso_*.img' -o \ + -iname 'kanso_*.bin' -o \ + -iname 'kanso_*.elf' -o \ + -iname 'kanso_*.tar.*' \ + \)) + [[ ${#FILES[@]} -gt 0 ]] || { echo "::error::No kanso_ artefacts"; exit 1; } printf '%s\n' "${FILES[@]}" { echo 'list<