Skip to content

Commit

Permalink
separated build and release
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Jul 14, 2024
1 parent 35a0f60 commit 8fc9d2d
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 137 deletions.
137 changes: 0 additions & 137 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,140 +61,3 @@ jobs:
with:
name: embedded-firmware
path: HeliosEmbedded/embedded\ firmware.zip

release:
if: github.event_name == 'workflow_dispatch'
needs: embedded
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for calculating version

- name: Get the latest tag
id: get_tag
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null || echo "none")
echo "tag=$latest_tag" >> $GITHUB_ENV
- name: Check for existing tags
id: check_tag
run: |
if [ "${{ env.tag }}" == "none" ]; then
echo "No tags found. Skipping release."
echo "skip_release=true" >> $GITHUB_ENV
else
echo "skip_release=false" >> $GITHUB_ENV
fi
- name: Calculate new version
if: env.skip_release == 'false'
id: calc_version
run: |
latest_tag=${{ env.tag }}
commits_since_tag=$(git rev-list $latest_tag..HEAD --count)
IFS='.' read -ra ADDR <<< "$latest_tag"
new_version="${ADDR[0]}.${ADDR[1]}.$((commits_since_tag))"
echo "new_version=$new_version" >> $GITHUB_ENV
echo "new_tag=$new_version" >> $GITHUB_ENV
- name: Create a new tag
if: env.skip_release == 'false'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git tag ${{ env.new_tag }}
git push origin ${{ env.new_tag }}
- name: Create GitHub Release
if: env.skip_release == 'false'
id: create_release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.new_tag }}
name: Helios Vortex ${{ env.new_version }}
body: |
Release of Helios Vortex version ${{ env.new_version }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Download HeliosCLI Artifact
if: env.skip_release == 'false'
uses: actions/download-artifact@v4
with:
name: helioscli-artifacts
path: ./artifact

- name: Unzip HeliosCLI Artifact
if: env.skip_release == 'false'
run: unzip ./artifact/helioscli.zip -d ./artifact/unzipped/helioscli

- name: Download HeliosEmbedded Artifact
if: env.skip_release == 'false'
uses: actions/download-artifact@v4
with:
name: embedded-firmware
path: ./artifact

- name: Unzip HeliosEmbedded Artifact
if: env.skip_release == 'false'
run: unzip ./artifact/embedded\ firmware.zip -d ./artifact/unzipped/embedded

- name: Upload Release Assets (helios.bin)
if: env.skip_release == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.bin
asset_name: helios.bin
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Assets (helios.elf)
if: env.skip_release == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.elf
asset_name: helios.elf
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Assets (helios.map)
if: env.skip_release == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.map
asset_name: helios.map
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Assets (helios.hex)
if: env.skip_release == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.hex
asset_name: helios.hex
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload HeliosCLI Artifacts
if: env.skip_release == 'false'
run: |
for file in ./artifact/unzipped/helioscli/*; do
gh release upload ${{ steps.create_release.outputs.upload_url }} "$file" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

140 changes: 140 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Helios Release

on:
workflow_dispatch: # manual trigger

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for calculating version

- name: Get the latest tag
id: get_tag
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null || echo "none")
echo "tag=$latest_tag" >> $GITHUB_ENV
- name: Check for existing tags
id: check_tag
run: |
if [ "${{ env.tag }}" == "none" ]; then
echo "No tags found. Skipping release."
echo "skip_release=true" >> $GITHUB_ENV
else
echo "skip_release=false" >> $GITHUB_ENV
fi
- name: Calculate new version
if: env.skip_release == 'false'
id: calc_version
run: |
latest_tag=${{ env.tag }}
commits_since_tag=$(git rev-list $latest_tag..HEAD --count)
IFS='.' read -ra ADDR <<< "$latest_tag"
new_version="${ADDR[0]}.${ADDR[1]}.$((commits_since_tag))"
echo "new_version=$new_version" >> $GITHUB_ENV
echo "new_tag=$new_version" >> $GITHUB_ENV
- name: Create a new tag
if: env.skip_release == 'false'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git tag ${{ env.new_tag }}
git push origin ${{ env.new_tag }}
- name: Create GitHub Release
if: env.skip_release == 'false'
id: create_release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.new_tag }}
name: Helios Vortex ${{ env.new_version }}
body: |
Release of Helios Vortex version ${{ env.new_version }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Download HeliosCLI Artifact
if: env.skip_release == 'false'
uses: actions/download-artifact@v4
with:
name: helioscli-artifacts
path: ./artifact

- name: Unzip HeliosCLI Artifact
if: env.skip_release == 'false'
run: unzip ./artifact/helioscli.zip -d ./artifact/unzipped/helioscli

- name: Download HeliosEmbedded Artifact
if: env.skip_release == 'false'
uses: actions/download-artifact@v4
with:
name: embedded-firmware
path: ./artifact

- name: Unzip HeliosEmbedded Artifact
if: env.skip_release == 'false'
run: unzip ./artifact/embedded\ firmware.zip -d ./artifact/unzipped/embedded

- name: Upload Release Assets (helios.bin)
if: env.skip_release == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.bin
asset_name: helios.bin
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Assets (helios.elf)
if: env.skip_release == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.elf
asset_name: helios.elf
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Assets (helios.map)
if: env.skip_release == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.map
asset_name: helios.map
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Assets (helios.hex)
if: env.skip_release == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.hex
asset_name: helios.hex
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload HeliosCLI Artifacts
if: env.skip_release == 'false'
run: |
for file in ./artifact/unzipped/helioscli/*; do
gh release upload ${{ steps.create_release.outputs.upload_url }} "$file" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 8fc9d2d

Please sign in to comment.