Skip to content

Commit

Permalink
Merge pull request #222 from espressif/feat/automatic_installer_release
Browse files Browse the repository at this point in the history
Feat/automatic installer release
  • Loading branch information
jakub-kocka authored Mar 25, 2024
2 parents 9ea3ef6 + 01ac791 commit 9bbe556
Show file tree
Hide file tree
Showing 9 changed files with 700 additions and 159 deletions.
53 changes: 33 additions & 20 deletions .github/workflows/build-espressif-ide-installer.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,92 @@
name: build-espressif-ide-installer

on:
workflow_dispatch:
workflow_call:
inputs:
espressif_ide_version:
description: 'Espressif IDE version'
required: true
default: '2.9.1'
esp_idf_version:
description: 'ESP-IDF version'
required: true
default: '5.0.1'
python_version:
description: 'Python version'
type: string
espressif_ide_version:
required: true
default: '3.11'
type: string

jobs:
build-espressif-ide-installer:
name: Build Installer
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Inputs Logged
run: |
echo "Received Espressif IDE Version: ${{ github.event.inputs.espressif_ide_version }}"
echo "Received ESP-IDF Version: ${{ github.event.inputs.esp_idf_version }}"
echo "Received Python Version: ${{ github.event.inputs.python_version }}"
- name: Map local long path to new drive
id: map_path
shell: pwsh
run: subst "p:" "$env:GITHUB_WORKSPACE"

- name: Install Inno Setup
shell: pwsh
run: choco install innosetup

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '${{ github.event.inputs.python_version }}'
python-version: '3.11'

- name: Install Inno Setup Download plugin
shell: pwsh
run: Invoke-WebRequest -Uri https://github.com/espressif/inno-download-plugin/releases/download/v1.5.1/idpsetup-1.5.1.exe -OutFile idpsetup.exe; .\idpsetup.exe /SILENT; Sleep 5

- name: Build Installer
env:
CERTIFICATE: ${{ secrets.CERTIFICATE }}
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
shell: pwsh
working-directory: "P:"
run: .\Build-Installer.ps1 -InstallerType espressif-ide -OfflineBranch "v${{ github.event.inputs.esp_idf_version }}" -EspressifIdeVersion "${{ github.event.inputs.espressif_ide_version }}"
run: .\Build-Installer.ps1 -InstallerType espressif-ide -OfflineBranch "v${{ inputs.esp_idf_version }}" -EspressifIdeVersion "${{ inputs.espressif_ide_version }}"

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: espressif-ide-${{ github.event.inputs.espressif_ide_version }}-esp-idf-${{ github.event.inputs.esp_idf_version }}
release_name: Release of Espressif IDE ${{ github.event.inputs.espressif_ide_version }} with ESP-IDF ${{ github.event.inputs.esp_idf_version }}
tag_name: espressif-ide-${{ inputs.espressif_ide_version }}-esp-idf-${{ inputs.esp_idf_version }}
release_name: Release of Espressif IDE ${{ inputs.espressif_ide_version }} with ESP-IDF ${{ inputs.esp_idf_version }}
draft: true
prerelease: true

- name: Get installer size and store it to file
run: |
echo $(Get-ItemProperty -Path .\build\espressif-ide-setup-espressif-ide-with-esp-idf-${{ inputs.esp_idf_version }}-signed.exe | Select-Object -ExpandProperty Length) > variables.txt
echo "Instaler size from variable is $(Get-Content variables.txt)"
- name: Upload artifacts of installer size
uses: actions/upload-artifact@v4
with:
name: installer-size
path: ./variables.txt

- name: Upload Release Asset To Github
id: 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: ./build/espressif-ide-setup-espressif-ide-with-esp-idf-${{ github.event.inputs.esp_idf_version }}-signed.exe
asset_name: espressif-ide-setup-${{ github.event.inputs.espressif_ide_version }}-with-esp-idf-${{ github.event.inputs.esp_idf_version }}.exe
asset_path: ./build/espressif-ide-setup-espressif-ide-with-esp-idf-${{ inputs.esp_idf_version }}-signed.exe
asset_name: espressif-ide-setup-${{ inputs.espressif_ide_version }}-with-esp-idf-${{ inputs.esp_idf_version }}.exe
asset_content_type: application/octet-stream

- name: Upload Release Asset To dl.espressif.com
id: upload-release-asset-espressif
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
shell: pwsh
run: aws s3 cp --acl=public-read --no-progress ./build/espressif-ide-setup-espressif-ide-with-esp-idf-${{ github.event.inputs.esp_idf_version }}-signed.exe s3://${{ secrets.DL_BUCKET }}/dl/idf-installer/espressif-ide-setup-${{ github.event.inputs.espressif_ide_version }}-with-esp-idf-${{ github.event.inputs.esp_idf_version }}.exe
run: aws s3 cp --acl=public-read --no-progress ./build/espressif-ide-setup-espressif-ide-with-esp-idf-${{ inputs.esp_idf_version }}-signed.exe s3://${{ secrets.DL_BUCKET }}/dl/idf-installer/espressif-ide-setup-${{ inputs.espressif_ide_version }}-with-esp-idf-${{ inputs.esp_idf_version }}.exe
123 changes: 123 additions & 0 deletions .github/workflows/build-installer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: build-installer-any

on:
workflow_dispatch:
inputs:
installer_type:
type: choice
description: 'Installer Type'
required: true
options:
- offline
- espressif-ide
- online
esp_idf_version:
description: 'ESP-IDF version (e.g. 5.2 or 5.2.1)'
required: false
default: ''
espressif_ide_version:
description: 'Espressif IDE version (e.g. 2.0.0)'
required: false
default: ''
online_installer_version:
description: 'Online Installer version (e.g. 2.0)'
required: false
default: ''

env:
INSTALLER_TYPE: ${{ inputs.installer_type }}
ESP_IDF_VERSION: ${{ inputs.esp_idf_version }}
ESPRESSIF_IDE_VERSION: ${{ inputs.espressif_ide_version }}
ONLINE_INSTALLER_VERSION: ${{ inputs.online_installer_version }}
# Based on this defined supported IDF versions are created installer buttons in index.html from releases.json
SUPPORTED_IDF_VERSIONS: ('5.2', '4.4', '5.1', '5.0')

jobs:
build-installer-online:
name: Build Online Installer
if: ${{ inputs.installer_type }} == 'online'
uses: espressif/idf-installer/.github/workflows/build-online-installer.yml@main
with:
online_installer_version: ${{ inputs.online_installer_version }}
secrets: inherit

build-installer-offline:
name: Build Offline Installer
if: ${{ inputs.installer_type }} == 'offline'
uses: espressif/idf-installer/.github/workflows/build-offline-installer.yml@main
with:
esp_idf_version: ${{ inputs.esp_idf_version}}
secrets: inherit

build-installer-ide:
name: Build IDE Installer
if: ${{ inputs.installer_type }} == 'espressif-ide'
uses: espressif/idf-installer/.github/workflows/build-espressif-ide-installer.yml@main
with:
esp_idf_version: ${{ inputs.esp_idf_version }}
espressif_ide_version: ${{ inputs.espressif_ide_version }}
secrets: inherit

update-docs-files:
needs: [build-installer-online, build-installer-offline, build-installer-ide]
name: Create ${{ inputs.installer_type}} installer release PR
if: ${{ always() }} && (${{ needs.build-installer-ide.result }} == 'success' || ${{ needs.build-installer-offline.result }} == 'success' || ${{ needs.build-installer-online.result }} == 'success')
runs-on: windows-latest
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: installer-size
path: ./

- name: Install script requirements
run: pip install -r scripts/requirements.txt

- name: Get size of online installer and Update docs files
run: |
echo "Instaler size from variable is $(Get-Content variables.txt)"
$size_bytes = [int]$(Get-Content variables.txt)
# Check if the content is larger than 100000
if ($size_bytes -gt 9999999) {
$result = [math]::Round($size_bytes / 1000000000,2)
$installer_size = "$result GB"
echo "INSTALLER_SIZE: $installer_size"
} else {
$result = [math]::Round($size_bytes / 1000000,2)
$installer_size = "$result MB"
echo "INSTALLER_SIZE: $installer_size"
}
python scripts/docs_update_release.py $installer_size
- name: Delete variables.txt
run: |
Remove-Item -Path variables.txt -Force
- name: Put current date into a variable
run: |
$DATE=& Get-Date -format yyyy-MM-dd
echo "DATE=$DATE" >> $env:GITHUB_ENV
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Release ${{ env.INSTALLER_TYPE }} installer ${{env.ESPRESSIF_IDE_VERSION}}${{env.ONLINE_INSTALLER_VERSION}} with ESP-IDF v${{ env.ESP_IDF_VERSION }}'
title: 'Release ${{ env.INSTALLER_TYPE }} installer ${{env.ESPRESSIF_IDE_VERSION}}${{env.ONLINE_INSTALLER_VERSION}} with ESP-IDF v${{ env.ESP_IDF_VERSION }}'
body: '- Updated docs files'
branch: 'release-${{ env.INSTALLER_TYPE }}${{ env.ESP_IDF_VERSION }}-installer'
delete-branch: true
base: 'main'
reviewers: georgik, jakub-kocka
57 changes: 33 additions & 24 deletions .github/workflows/build-offline-installer.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,62 @@
name: build-offline-installer

on:
workflow_dispatch:

push:
tags:
- offline-*
workflow_call:
inputs:
esp_idf_version:
required: true
type: string

env:
IDF_BRANCH: ${{ inputs.esp_idf_version }}
VERSION: 'offline-${{ inputs.esp_idf_version }}'

jobs:
build-offline-installer:
name: Build Installer
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
shell: bash
- name: Get the installer type
id: get_installer_type
run: echo ::set-output name=INSTALLER_TYPE::${${{ steps.get_version.outputs.VERSION }}//-*}
shell: bash
- name: Get version for branch
id: get_branch_version
run: echo ::set-output name=BRANCH_VERSION::${GITHUB_REF/refs\/tags\/offline-/}
shell: bash
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install Inno Setup Download plugin
shell: pwsh
run: Invoke-WebRequest -Uri https://github.com/espressif/inno-download-plugin/releases/download/v1.5.1/idpsetup-1.5.1.exe -OutFile idpsetup.exe; .\idpsetup.exe /SILENT; Sleep 5

- name: Build Installer
env:
CERTIFICATE: ${{ secrets.CERTIFICATE }}
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
shell: pwsh
run: .\Build-Installer.ps1 -InstallerType offline -OfflineBranch v${{ steps.get_branch_version.outputs.BRANCH_VERSION }}
run: .\Build-Installer.ps1 -InstallerType offline -OfflineBranch v${{ env.IDF_BRANCH }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
tag_name: ${{ env.VERSION }}-esp-idf-v${{ env.IDF_BRANCH }}
release_name: Release ${{ env.VERSION }}
draft: false
prerelease: false

- name: Get installer size and store it to file
run: |
echo $(Get-ItemProperty -Path .\build\esp-idf-tools-setup-offline-signed.exe | Select-Object -ExpandProperty Length) > variables.txt
echo "Instaler size from variable is $(Get-Content variables.txt)"
- name: Upload artifacts of installer size
uses: actions/upload-artifact@v4
with:
name: installer-size
path: ./variables.txt

- name: Upload Release Asset To Github
id: upload-release-asset
uses: actions/upload-release-asset@v1
Expand All @@ -57,13 +65,14 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/esp-idf-tools-setup-offline-signed.exe
asset_name: esp-idf-tools-setup-${{ steps.get_version.outputs.VERSION }}.exe
asset_name: esp-idf-tools-setup-${{ env.VERSION }}.exe
asset_content_type: application/octet-stream

- name: Upload Release Asset To dl.espressif.com
id: upload-release-asset-espressif
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
shell: pwsh
run: aws s3 cp --acl=public-read --no-progress ./build/esp-idf-tools-setup-offline-signed.exe s3://${{ secrets.DL_BUCKET }}/dl/idf-installer/esp-idf-tools-setup-${{ steps.get_version.outputs.VERSION }}.exe
run: aws s3 cp --acl=public-read --no-progress ./build/esp-idf-tools-setup-offline-signed.exe s3://${{ secrets.DL_BUCKET }}/dl/idf-installer/esp-idf-tools-setup-${{ env.VERSION }}.exe
Loading

0 comments on commit 9bbe556

Please sign in to comment.