Skip to content

Release

Release #21

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version_tag:
description: 'Version tag'
required: true
type: string
workflow_call:
inputs:
version_tag:
description: 'Version tag'
required: true
type: string
jobs:
build:
uses: ./.github/workflows/build.yml
with:
upload_artifacts: true
secrets: inherit
release:
needs: build
runs-on: ubuntu-latest
env:
version_tag: ${{ inputs.version_tag }}
steps:
- name: Check for curl
run: type -p curl >/dev/null || (sudo apt-get update && sudo apt-get install curl -y)
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
BRANCH: ${{ steps.extract_branch.outputs.branch }}
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ env.OWNER }}/${{ env.REPO }}/releases" \
-d '{"tag_name":"${{ env.version_tag }}","target_commitish":"${{ env.BRANCH }}","body":"___This release was automatically generated when the app version increased___","draft":false,"prerelease":false,"generate_release_notes":true}' \
-o release.json
echo "upload_url=$(grep -Po '(?:\G(?!^)",|"upload_url":\s*)\s*"\K[^"{]+' release.json)" >> "$GITHUB_ENV"
html_url=$(grep -Po -m 1 '(?:\G(?!^)",|"html_url":\s*)\s*"\K[^"]+' release.json)
echo "Created release [${{ env.version_tag }}]($html_url)" >> $GITHUB_STEP_SUMMARY
- name: Download merged.hex
uses: actions/download-artifact@v4
with:
name: ${{ steps.extract_branch.outputs.branch }}_merged.hex
- name: Download app_update.bin
uses: actions/download-artifact@v4
with:
name: ${{ steps.extract_branch.outputs.branch }}_app_update.bin
- name: Upload merged.hex
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
BRANCH: ${{ steps.extract_branch.outputs.branch }}
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ env.upload_url }}?name=${{ env.BRANCH }}_merged.hex" \
--data-binary "@${{ env.BRANCH }}_merged.hex"
echo 'Uploaded build artifact ${{ env.BRANCH }}_merged.hex as asset to release' >> $GITHUB_STEP_SUMMARY
- name: Upload merged_sha256.sum
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
BRANCH: ${{ steps.extract_branch.outputs.branch }}
run: |
sha256sum merged.hex > merged_sha256.sum
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ env.upload_url }}?name=${{ env.BRANCH }}_merged_sha256.sum" \
--data-binary "@${{ env.BRANCH }}_merged_sha256.sum"
echo 'Uploaded build artifact ${{ env.BRANCH }}_merged_sha256.sum as asset to release' >> $GITHUB_STEP_SUMMARY
- name: Upload app_update.bin
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
BRANCH: ${{ steps.extract_branch.outputs.branch }}
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ env.upload_url }}?name=${{ env.BRANCH }}_app_update.bin" \
--data-binary "@${{ env.BRANCH }}_app_update.bin"
echo 'Uploaded build artifact ${{ env.BRANCH }}_app_update.bin as asset to release' >> $GITHUB_STEP_SUMMARY
- name: Upload app_update_sha256.sum
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
BRANCH: ${{ steps.extract_branch.outputs.branch }}
run: |
sha256sum app_update.bin > app_update_sha256.sum
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ env.upload_url }}?name=${{ env.BRANCH }}_app_update_sha256.sum" \
--data-binary "@${{ env.BRANCH }}_app_update_sha256.sum"
echo 'Uploaded build artifact ${{ env.BRANCH }}_app_update_sha256.sum as asset to release' >> $GITHUB_STEP_SUMMARY