Skip to content

Commit

Permalink
Create release workflow (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
webhdx authored Aug 11, 2024
1 parent d498cfe commit 8447c47
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/00-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Tag and Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version to tag'
required: true
default: 'v0.4'
type: string
is_draft:
description: 'Is draft release?'
default: false
type: boolean
is_prerelease:
description: 'Is prerelease?'
default: false
type: boolean
name:
description: 'Name'
required: false
default: ''
type: string
release_description:
description: 'Release description (Markdown supported)'
required: false
default: ''
type: string

jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Tag the branch
working-directory: ${{ github.workspace }}
run: |
git tag ${{ github.event.inputs.version }}
git push origin ${{ github.event.inputs.version }}
build:
needs: tag
uses: ./.github/workflows/10-build.yml

release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-tags: true

- name: Get commit hash
id: vars
run: |
git tag
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Determine Release Name
id: determine_name
run: |
if [ -z "${{ github.event.inputs.name }}" ]; then
echo "name=PicoBoot ${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "name=${{ github.event.inputs.name }}" >> $GITHUB_OUTPUT
fi
- name: Retrieve artifact
uses: actions/download-artifact@v4
with:
name: picoboot-${{ steps.vars.outputs.sha_short }}
path: dist/

- name: Prepare release description
run: |
touch release-description.md
echo "${{ github.event.inputs.release_description }}" >> release-description.md
- name: Calculate artifact checksum
run: |
echo '```' >> release-description.md
cd dist/
sha256sum picoboot_full.uf2 >> ../release-description.md
cd ../
echo '```' >> release-description.md
- name: Set up Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
release_name: ${{ steps.determine_name.outputs.name }}
body_path: ${{ github.workspace }}/release-description.md
draft: ${{ github.event.inputs.is_draft }}
prerelease: ${{ github.event.inputs.is_prerelease }}

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/dist/picoboot_full.uf2
asset_name: picoboot_full.uf2
asset_content_type: application/octet-stream
2 changes: 2 additions & 0 deletions .github/workflows/10-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
branches:
- main

workflow_call:

env:
# Customize the CMake build
BUILD_TYPE: RelWithDebInfo # Release, Debug, RelWithDebInfo
Expand Down

0 comments on commit 8447c47

Please sign in to comment.