This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and release | ||
|
Check failure on line 1 in .github/workflows/build.yml
|
||
| env: | ||
| CI: false | ||
| BUILD_VERSION: ${{ vars.VERSION }}.${{ vars.MAJOR }}.${{ vars.MINOR }}.${{ github.run_number }} | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| jobs: | ||
| build-and-release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
| - name: Determine Docker image tag | ||
| id: docker_tag | ||
| run: | | ||
| IMAGE_TAG="${{vars.MICROPYTHON_VERSION}}" | ||
| IMAGE_NAME="rav3nh01m/micropython:$IMAGE_TAG" | ||
| echo "Checking for image: $IMAGE_NAME" | ||
| if docker pull "$IMAGE_NAME"; then | ||
| echo "Using tag: $IMAGE_TAG" | ||
| else | ||
| echo "Tag not found. Falling back to latest." | ||
| IMAGE_TAG="latest" | ||
| docker pull "rav3nh01m/micropython:latest" | ||
| fi | ||
| echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT | ||
| - name: Run MicroPython build container | ||
| image: rav3nh01m/micropython:latest | ||
| env: | ||
| PORT: ${{vars.PORT}} | ||
| BOARD: ${{vars.BOARD}} | ||
| FREEZE_BOOT: ${{vars.FREEZE_BOOT}} | ||
| FREEZE_MAIN: ${{vars.FREEZE_MAIN}} | ||
| - name: Copy firmware UF2 | ||
| run: | | ||
| cp ./firmware/dist/firmware.uf2 ./release/firmware-v${{env.BUILD_VERSION}}.uf2 | ||
| - name: Create firmware zip | ||
| working-directory: ./release | ||
| run: zip -j firmware-v${{env.BUILD_VERSION}}.zip firmware-v${{env.BUILD_VERSION}}.uf2 | ||
| - name: Clean firmware modules & manifest | ||
| run: | | ||
| rm -rf ./firmware/modules | ||
| rm -f ./firmware/manifest.py | ||
| - name: Set code version | ||
| working-directory: ./firmware/config | ||
| run: | | ||
| jq ".code_version = \"${{env.BUILD_VERSION}}\"" controller.json > temp.json \ | ||
| && mv temp.json controller.json | ||
| - name: Create code directory | ||
| run: mkdir -p ./release/code | ||
| - name: Copy .vscode | ||
| working-directory: ./firmware | ||
| run: | | ||
| if [ -d ".vscode" ]; then | ||
| cp -R .vscode ${{github.workspace}}/release/code/ | ||
| echo "Copied .vscode" | ||
| else | ||
| echo ".vscode directory not found — skipping" | ||
| fi | ||
| - name: Copy lib | ||
| working-directory: ./firmware | ||
| run: | | ||
| if [ -d "lib" ]; then | ||
| cp -R lib ${{github.workspace}}/release/code/ | ||
| echo "Copied lib" | ||
| else | ||
| echo "lib directory not found — skipping" | ||
| fi | ||
| - name: Copy config | ||
| working-directory: ./firmware | ||
| run: | | ||
| if [ -d "config" ]; then | ||
| cp -R config ${{github.workspace}}/release/code/ | ||
| echo "Copied config" | ||
| else | ||
| echo "config directory not found — skipping" | ||
| fi | ||
| - name: Copy main.py (if not frozen) | ||
| if: ${{ vars.FREEZE_MAIN != 'true' }} | ||
| working-directory: ./firmware | ||
| run: | | ||
| if [ -f "main.py" ]; then | ||
| cp main.py ${{github.workspace}}/release/code/ | ||
| echo "Copied main.py" | ||
| else | ||
| echo "main.py not found — skipping" | ||
| fi | ||
| - name: Copy boot.py (if not frozen) | ||
| if: ${{ vars.FREEZE_BOOT != 'true' }} | ||
| working-directory: ./firmware | ||
| run: | | ||
| if [ -f "boot.py" ]; then | ||
| cp boot.py ${{github.workspace}}/release/code/ | ||
| echo "Copied main.py" | ||
| else | ||
| echo "boot.py not found — skipping" | ||
| fi | ||
| - name: Create code zip | ||
| working-directory: ./release/code | ||
| run: zip -r ../code-v${{env.BUILD_VERSION}}.zip . | ||
| - name: Authenticate Git | ||
| run: git remote set-url origin https://x-access-token:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}} | ||
| - name: Create tag | ||
| run: | | ||
| git config user.name "github-actions" | ||
| git config user.email "github-actions@github.com" | ||
| git tag v${{env.BUILD_VERSION}} | ||
| git push origin v${{env.BUILD_VERSION}} | ||
| - name: Create Release | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: v${{env.BUILD_VERSION}} | ||
| name: Release v${{env.BUILD_VERSION}} | ||
| prerelease: ${{vars.IS_PRERELEASE}} | ||
| files: | | ||
| ./release/firmware-v${{env.BUILD_VERSION}}.zip | ||
| ./release/code-v${{env.BUILD_VERSION}}.zip | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||