Skip to content

Commit

Permalink
ci: experiment with release template generation
Browse files Browse the repository at this point in the history
upload ready-to-use template for the draft
changelog url has no anchor, though
  • Loading branch information
mcspr committed Jan 15, 2025
1 parent 06c41fe commit db17193
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/release_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ When updating from 1.14.1 make sure **there is enough available space on the dev

Make sure to **only** perform OTA upgrade with a properly powered device. Attempting to flash and / or use a normally AC powered device (like a Sonoff) instead powered through 3v3 **may** result in unexpected issues with the firmware.

# Snapshot build
# Snapshot build $$DATE$$

**How to upgrade "over-the-air" aka OTA**: https://github.com/xoseperez/espurna/wiki/OTA
**Latest changes**: https://github.com/xoseperez/espurna/compare/$last_tag...$tag
**CHANGELOG.md**: https://github.com/xoseperez/espurna/blob/$tag/CHANGELOG.md
**Latest changes**: https://github.com/xoseperez/espurna/compare/$$LAST_TAG$$...$$BUILD_TAG$$
**CHANGELOG.md**: https://github.com/xoseperez/espurna/blob/$$BUILD_TAG$$/CHANGELOG.md

# Build from source

Expand Down
37 changes: 29 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,39 @@ jobs:
variables:
runs-on: ubuntu-latest
outputs:
build_tag: ${{ steps.result.outputs.build_tag }}
date: ${{ steps.result.outputs.date }}
dev: ${{ steps.result.outputs.dev }}
master: ${{ steps.result.outputs.master }}
last_tag: ${{ steps.result.outputs.last }}

steps:
- name: Prepare version variables
id: result
shell: bash
run: |
revision() {
remote_last_tag() {
git ls-remote --tags --sort='version:refname' https://github.com/xoseperez/espurna 'github*' |\
cut -d'/' -f3 |\
grep -o -E '^github[0-9]{6}$' |\
sort -r |\
head -1
}
remote_revision() {
git ls-remote --exit-code --heads https://github.com/xoseperez/espurna.git refs/heads/$1 | cut -d$'\t' -f1
}
date=$(date +'%y%m%d')
echo "date=${date}" >> "$GITHUB_OUTPUT"
dev=$(revision dev)
dev=$(remote_revision dev)
echo "dev=${dev}" >> "$GITHUB_OUTPUT"
master=$(revision master)
echo "master=${master}" >> "$GITHUB_OUTPUT"
last=$(remote_last_tag)
echo "last_tag=${last}" >> "$GITHUB_OUTPUT"
build="github${date}"
echo "build_tag=${build}" >> "$GITHUB_OUTPUT"
build:
needs: variables
Expand Down Expand Up @@ -130,19 +143,27 @@ jobs:
'build/debug/*.map' \
'build/debug/*.elf.debug'
- name: Fetch release template
- name: Fetch and render release template
run: |
curl \
-H "Authentication: ${{ secrets.GITUB_TOKEN }}" \
-H "Accept: application/vnd.github.VERSION.raw" \
-o release_template.md \
https://api.github.com/repos/xoseperez/espurna/contents/.github/release_template.md
- name: Render release template
run: |
sed \
-i \
-e 's/\$\$BUILD_TAG\$\$/'${{ needs.variables.outputs.build_tag }}'/g' \
-e 's/\$\$LAST_TAG\$\$/'${{ needs.variables.outputs.last_tag }}'/g' \
release_template.md
- uses: ncipollo/release-action@v1
with:
tag: github${{ needs.variables.outputs.date }}
tag: ${{ needs.variables.outputs.build_tag }}
commit: ${{ needs.variables.outputs.dev }}
name: Snapshot build (github${{ needs.variables.outputs.date }})
name: Snapshot build (${{ needs.variables.outputs.build_tag }})
bodyFile: "release_template.md"
artifacts: "Debug.zip,build/*.bin"
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release (test)

on:
workflow_dispatch:

jobs:
variables:
runs-on: ubuntu-latest
outputs:
build_tag: ${{ steps.result.outputs.build_tag }}
date: ${{ steps.result.outputs.date }}
dev: ${{ steps.result.outputs.dev }}
last_tag: ${{ steps.result.outputs.last }}

steps:
- name: Prepare version variables
id: result
shell: bash
run: |
remote_last_tag() {
git ls-remote --tags --sort='version:refname' https://github.com/xoseperez/espurna 'github*' |\
cut -d'/' -f3 |\
grep -o -E '^github[0-9]{6}$' |\
sort -r |\
head -1
}
remote_revision() {
git ls-remote --exit-code --heads https://github.com/xoseperez/espurna.git refs/heads/$1 | cut -d$'\t' -f1
}
date=$(date +'%y%m%d')
echo "date=${date}" >> "$GITHUB_OUTPUT"
dev=$(remote_revision dev)
echo "dev=${dev}" >> "$GITHUB_OUTPUT"
last=$(remote_last_tag)
echo "last_tag=${last}" >> "$GITHUB_OUTPUT"
build="github${date}"
echo "build_tag=${build}" >> "$GITHUB_OUTPUT"
release:
needs: variables
runs-on: ubuntu-latest
steps:
- name: Fetch release template
run: |
curl \
-H "Authentication: ${{ secrets.GITUB_TOKEN }}" \
-H "Accept: application/vnd.github.VERSION.raw" \
-o release_template.md \
https://api.github.com/repos/xoseperez/espurna/contents/.github/release_template.md
- name: Render release template
run: |
sed \
-i \
-e 's/\$\$DATE\$\$/'${{ needs.variables.outputs.date }}'/g' \
-e 's/\$\$BUILD_TAG\$\$/'${{ needs.variables.outputs.build_tag }}'/g' \
-e 's/\$\$LAST_TAG\$\$/'${{ needs.variables.outputs.last_tag }}'/g' \
release_template.md
- uses: actions/upload-artifact@v4
with:
name: release_template.md
path: release_template.md

0 comments on commit db17193

Please sign in to comment.