mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-12-02 11:13:03 +05:00
feat: create draft releases for version tags on master
This commit is contained in:
1 parent
f4264cc765
commit
c7f44bf8cb
1 file changed
+65
-2
@@ -36,16 +36,27 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
envs: ${{ steps.envs.outputs.envs }}
|
envs: ${{ steps.envs.outputs.envs }}
|
||||||
env_titles: ${{ steps.envs.outputs.env_titles }}
|
env_titles: ${{ steps.envs.outputs.env_titles }}
|
||||||
|
release_branch: ${{ steps.release_branch.outputs.branch }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
# A new tag needs branch history to determine whether its commit is on master.
|
||||||
|
fetch-depth: ${{ startsWith(github.ref, 'refs/tags/v') && github.event.created && '0' || '1' }}
|
||||||
|
|
||||||
- name: Python
|
- name: Python
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: ${{ env.PYTHON_VERSION }}
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
|
- name: Check tagged commit on master
|
||||||
|
id: release_branch
|
||||||
|
if: github.event_name == 'push' && github.event.created && startsWith(github.ref, 'refs/tags/v')
|
||||||
|
run: |
|
||||||
|
branch=$(git branch --remotes --contains HEAD --list origin/master --format='%(refname:short)')
|
||||||
|
echo "branch=$branch" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Install PlatformIO Core
|
- name: Install PlatformIO Core
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
@@ -105,6 +116,17 @@ jobs:
|
|||||||
pip install --upgrade platformio
|
pip install --upgrade platformio
|
||||||
pip install --upgrade intelhex
|
pip install --upgrade intelhex
|
||||||
|
|
||||||
|
- name: Set firmware version from tag
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v') && !github.event.deleted
|
||||||
|
run: |
|
||||||
|
version="${GITHUB_REF_NAME#v}"
|
||||||
|
if [[ ! $version =~ ^[0-9][a-zA-Z0-9.+-]*$ ]]; then
|
||||||
|
echo "::error::Expected a version tag such as v2.0.0 or v2.0.0-rc.1."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sed -i -E "s/^custom_version[[:blank:]]*=.*/custom_version = $version/" platformio.ini
|
||||||
|
echo "RELEASE_VERSION=$version" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Full clean
|
- name: Full clean
|
||||||
run: |
|
run: |
|
||||||
pio run -e ${{ matrix.env }} -t fullclean
|
pio run -e ${{ matrix.env }} -t fullclean
|
||||||
@@ -115,6 +137,26 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pio run -e ${{ matrix.env }}
|
pio run -e ${{ matrix.env }}
|
||||||
|
|
||||||
|
- name: Check release files
|
||||||
|
if: env.RELEASE_VERSION != ''
|
||||||
|
working-directory: build
|
||||||
|
env:
|
||||||
|
BOARD: ${{ matrix.env }}
|
||||||
|
run: |
|
||||||
|
files=(
|
||||||
|
"firmware_${BOARD}_${RELEASE_VERSION}.bin"
|
||||||
|
"firmware_${BOARD}_${RELEASE_VERSION}.factory.bin"
|
||||||
|
"firmware_${BOARD}_${RELEASE_VERSION}.elf"
|
||||||
|
"filesystem_${BOARD}_${RELEASE_VERSION}.bin"
|
||||||
|
)
|
||||||
|
|
||||||
|
for file in "${files[@]}"; do
|
||||||
|
if [[ ! -s "$file" ]]; then
|
||||||
|
echo "::error::Release file missing or empty: $file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
@@ -125,12 +167,14 @@ jobs:
|
|||||||
build/*.elf
|
build/*.elf
|
||||||
|
|
||||||
release:
|
release:
|
||||||
name: Release Unstable
|
name: Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [prepare, build]
|
needs: [prepare, build]
|
||||||
|
if: >-
|
||||||
|
github.repository_owner == 'Laxilef' && github.event_name == 'push' &&
|
||||||
|
(github.ref == 'refs/heads/dev' || needs.prepare.outputs.release_branch == 'origin/master')
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
if: ${{ github.repository_owner == 'Laxilef' && github.ref == 'refs/heads/dev' }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -139,6 +183,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Move unstable tag
|
- name: Move unstable tag
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
run: |
|
run: |
|
||||||
git fetch --tags
|
git fetch --tags
|
||||||
git tag -f unstable
|
git tag -f unstable
|
||||||
@@ -157,6 +202,7 @@ jobs:
|
|||||||
run: python3 tools/generate_webflasher.py --envs "$ENVS" --titles "$ENV_TITLES"
|
run: python3 tools/generate_webflasher.py --envs "$ENVS" --titles "$ENV_TITLES"
|
||||||
|
|
||||||
- name: Delete old release assets
|
- name: Delete old release assets
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
uses: mknejp/delete-release-assets@v1
|
uses: mknejp/delete-release-assets@v1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -169,12 +215,14 @@ jobs:
|
|||||||
webflasher.json
|
webflasher.json
|
||||||
|
|
||||||
- name: Clear release body
|
- name: Clear release body
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
gh release edit unstable --notes ""
|
gh release edit unstable --notes ""
|
||||||
|
|
||||||
- name: Publish Unstable release
|
- name: Publish Unstable release
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
uses: softprops/action-gh-release@v3
|
uses: softprops/action-gh-release@v3
|
||||||
with:
|
with:
|
||||||
tag_name: unstable
|
tag_name: unstable
|
||||||
@@ -183,6 +231,21 @@ jobs:
|
|||||||
prerelease: true
|
prerelease: true
|
||||||
make_latest: false
|
make_latest: false
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
fail_on_unmatched_files: true
|
||||||
|
files: |
|
||||||
|
artifacts/*.bin
|
||||||
|
artifacts/*.elf
|
||||||
|
artifacts/webflasher.json
|
||||||
|
|
||||||
|
- name: Publish new release
|
||||||
|
if: github.ref_type == 'tag'
|
||||||
|
uses: softprops/action-gh-release@v3
|
||||||
|
with:
|
||||||
|
draft: true
|
||||||
|
prerelease: false
|
||||||
|
make_latest: true
|
||||||
|
generate_release_notes: true
|
||||||
|
fail_on_unmatched_files: true
|
||||||
files: |
|
files: |
|
||||||
artifacts/*.bin
|
artifacts/*.bin
|
||||||
artifacts/*.elf
|
artifacts/*.elf
|
||||||
|
|||||||
Reference in new issue
Block a user