| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- name: UFBT Build and Release
- permissions:
- contents: write
- on:
- push:
- branches:
- - main
- pull_request:
- branches:
- - main
- jobs:
- build:
- name: Build and Test Application
- runs-on: ubuntu-latest
- steps:
- - name: Checkout Repository
- uses: actions/checkout@v3
- - name: Set up Python
- uses: actions/setup-python@v4
- with:
- python-version: '3.x'
- - name: Install UFBT
- run: |
- python3 -m pip install --upgrade pip
- pip install ufbt
- - name: Initialize UFBT Environment
- run: |
- ufbt update
- ufbt vscode_dist
- - name: Build FAP Applications
- run: ufbt faps
- - name: Upload Build Artifacts
- uses: actions/upload-artifact@v3
- with:
- name: build-output
- path: build/
- release:
- name: Create Release
- needs: build
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
- runs-on: ubuntu-latest
- steps:
- - name: Checkout Repository
- uses: actions/checkout@v3
- - name: Extract Version from Manifest
- id: extract_version
- run: |
- VERSION=$(grep '^version:' manifest.yml | awk '{print $2}')
- echo "VERSION=${VERSION}" >> $GITHUB_ENV
- - name: Check if Release Exists
- id: check_release
- run: |
- REPO="luu176/Metroflip"
- TAG="v${{ env.VERSION }}"
- RELEASE_EXISTS=$(curl -s https://api.github.com/repos/$REPO/releases/tags/$TAG)
- echo "RELEASE_EXISTS=$RELEASE_EXISTS"
- if [[ $RELEASE_EXISTS == *"Not Found"* ]]; then
- echo "Release not found. Creating new release."
- echo "create=true" >> $GITHUB_ENV
- else
- echo "Release found. Deleting existing release."
- RELEASE_ID=$(echo $RELEASE_EXISTS | jq -r '.id')
- curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/releases/$RELEASE_ID
- echo "create=true" >> $GITHUB_ENV
- fi
- - name: Create Release
- id: create_release
- if: env.create == 'true'
- uses: actions/create-release@v1
- with:
- tag_name: v${{ env.VERSION }}
- release_name: Metroflip v${{ env.VERSION }}
- body: |
- **What's New:**
- $(cat CHANGELOG.md)
- draft: false
- prerelease: false
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: Upload FAP File to Release
- if: env.create == 'true'
- uses: actions/upload-release-asset@v1
- with:
- upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: build/fap/metroflip-${{ env.VERSION }}.fap
- asset_name: metroflip-${{ env.VERSION }}.fap
- asset_content_type: application/octet-stream
|