yaml not yml for filenames #3
This file contains 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: Prepare a new release and add release assets | ||
on: | ||
workflow_call: | ||
env: | ||
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }} | ||
jobs: | ||
verify_library_structure: | ||
name: Validate library structure | ||
uses: ./.github/workflows/verify_library_structure.yaml@main | ||
check_for_dependencies: | ||
name: Check if there are any library dependencies | ||
uses: ./.github/workflows/check_for_dependencies.yaml@main | ||
check_version_number: | ||
name: Prepare release assets containing dependencies | ||
runs-on: ubuntu-latest | ||
outputs: | ||
current_version: ${{ steps.set_vesion.outputs.version }} | ||
zip_name: ${{ steps.set_vesion.outputs.zip_name }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set environment variable for current library version | ||
id: set_vesion | ||
run: | | ||
echo "::debug::Get the current version number" | ||
VER=$(cat VERSION) | ||
ZIP_FILE="${GITHUB_REPOSITORY#*/}_Dependencies_${VER}" | ||
echo "VERSION=$VER" >> $GITHUB_ENV | ||
echo "ZIP_NAME=$ZIP_FILE" >> $GITHUB_ENV | ||
prepare_assets: | ||
name: Prepare release assets containing dependencies | ||
runs-on: ubuntu-latest | ||
needs: [check_for_dependencies, check_version_number] | ||
if: ${{ needs.check_for_dependencies.outputs.has_dependencies }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set up python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
- name: Install PlatformIO | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --upgrade platformio | ||
# Install all the library dependencies! | ||
- name: Install the library dependencies to zip up for the release | ||
id: install_release_deps | ||
run: | | ||
chmod +x continuous_integration/install-libraries-platformio.sh | ||
sh continuous_integration/install-libraries-platformio.sh | ||
- name: Install the library from the master branch | ||
run: | | ||
pio pkg install -g -l https://github.com/EnviroDIY/${GITHUB_REPOSITORY#*/} | ||
# Uninstall graphics libraries from Adafruit | ||
- name: Uninstall Adafruit GFX Library library | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing Adafruit GFX Library" | ||
pio pkg uninstall -g -l "adafruit/Adafruit GFX Library" | ||
- name: Uninstall Adafruit NeoPixel library | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing Adafruit NeoPixel" | ||
pio pkg uninstall -g -l "adafruit/Adafruit NeoPixel" | ||
- name: Uninstall Adafruit SSD1306 library | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing Adafruit SSD1306" | ||
pio pkg uninstall -g -l "adafruit/Adafruit SSD1306" | ||
- name: Uninstall Adafruit ADXL343 library | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing Adafruit ADXL343" | ||
pio pkg uninstall -g -l "adafruit/Adafruit ADXL343" | ||
- name: Uninstall Adafruit STMPE610 library | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing Adafruit STMPE610" | ||
pio pkg uninstall -g -l "adafruit/Adafruit STMPE610" | ||
- name: Uninstall Adafruit TouchScreen library | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing Adafruit TouchScreen" | ||
pio pkg uninstall -g -l "adafruit/Adafruit TouchScreen" | ||
- name: Uninstall Adafruit ILI9341 library | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing Adafruit ILI9341" | ||
pio pkg uninstall -g -l "adafruit/Adafruit ILI9341" | ||
# zip up all the installed libraries | ||
# need to cd into the pio directory so we don't get extra junk directories | ||
- name: Zip libraries | ||
run: | | ||
echo "::debug::Listing global libraries" | ||
pio pkg list -g -v --only-libraries | ||
echo "::debug::Zipping global libraries" | ||
cd /home/runner/.platformio/ | ||
zip ${{ needs.check_version_number.outputs.zip_name }}.zip -r lib | ||
mv ${{ needs.check_version_number.outputs.zip_name }}.zip $GITHUB_WORKSPACE | ||
cd $GITHUB_WORKSPACE | ||
ls | ||
# Remove some extras from the zip | ||
- name: Remove git files from the zip | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Deleting extra files to decrease size of zip" | ||
echo "::debug::Removing Git folders" | ||
zip -d -q ${{ needs.check_version_number.outputs.zip_name }} "*/.gitattributes" "*/.gitignore" "*/.gitmodules" "*/.github/*" "*.sh" "*/Doxyfile" "*/.travis.yml" | ||
- name: Remove other pdfs from the zip | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing other pdfs" | ||
zip -d -q libraries "*/doc/*.pdf" | ||
- name: Remove TinyGSM extras from the zip | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing TinyGSM extras" | ||
zip -d -q libraries "*/TinyGSM/extras/*" | ||
- name: Remove YosemitechModbus extras from the zip | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing YosemitechModbus extras" | ||
zip -d -q libraries "*/YosemitechModbus/doc/*" | ||
- name: Remove SDFat extras from the zip | ||
continue-on-error: true | ||
run: | | ||
echo "::debug::Removing SDFat extras" | ||
zip -d -q libraries "*/SdFat/extras/*" | ||
- name: Store generated dependency zip | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dependency_zip | ||
path: | | ||
${{ needs.check_version_number.outputs.zip_name }}.zip | ||
release: | ||
name: Prepare a new release | ||
runs-on: ubuntu-latest | ||
needs: [check_for_dependencies, check_version_number] | ||
steps: | ||
- name: Get change log entry for release notes | ||
id: changelog_reader | ||
uses: mindsers/changelog-reader-action@v2 | ||
with: | ||
path: ChangeLog.md | ||
version: ${{ needs.check_version_number.outputs.current_version }} | ||
- name: Download the prepared dependency zip | ||
if: ${{ needs.check_for_dependencies.outputs.has_dependencies }} | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: dependency_zip | ||
# Create a new release with zipped dependencies | ||
- name: Create release with assets | ||
if: ${{ needs.check_for_dependencies.outputs.has_dependencies }} | ||
id: create_release_with_zip | ||
uses: softprops/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ format('v{0}',needs.check_version_number.outputs.current_version) }} | ||
name: ${{ format('v{0}',needs.check_version_number.outputs.current_version) }} | ||
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }} | ||
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }} | ||
body: ${{ steps.changelog_reader.outputs.changes }} | ||
generate_release_notes: false | ||
files: ${{ format('./{0}.zip', needs.check_version_number.outputs.zip_name) }} | ||
fail_on_unmatched_files: true | ||
# Create a new release with no zip | ||
- name: Create release with assets | ||
id: create_bare_release | ||
if: ${{ ! needs.check_for_dependencies.outputs.has_dependencies }} | ||
uses: softprops/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ format('v{0}',needs.check_version_number.outputs.current_version) }} | ||
name: ${{ format('v{0}',needs.check_version_number.outputs.current_version) }} | ||
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }} | ||
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }} | ||
body: ${{ steps.changelog_reader.outputs.changes }} | ||
generate_release_notes: false | ||
# Publish the new release to the PlatformIO package manager | ||
- name: Publish release to the PlatformIO package manager | ||
id: publish-pio | ||
run: pio package publish --owner envirodiy --non-interactive |