Workflow file for this run
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: Update Version and Create Zip on Release | |
on: | |
workflow_dispatch: | |
release: | |
types: [published, edited] | |
jobs: | |
update_version_and_create_zip: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Debug Variables | |
run: | | |
echo "github.event_name: ${{ github.event_name }}" | |
echo "github.ref_name: ${{ github.ref_name }}" | |
echo "github.event.repository.default_branch: ${{ github.event.repository.default_branch }}" | |
echo "github.event.release.target_commitish: ${{ github.event.release.target_commitish }}" | |
echo "github.event.release.prerelease: ${{ github.event.release.prerelease }}" | |
echo "github.event.release.draft: ${{ github.event.release.draft }}" | |
- name: Update Version in Manifest | |
if: ${{ github.event_name == 'release' && github.event.release.draft == false }} | |
run: | | |
sed -i 's/\"version\"\s*\:\s*\".*\"/\"version\"\:\"${{ github.ref_name }}\"/g' ./custom_components/opnsense/manifest.json | |
- name: Update Version in const.py | |
if: ${{ github.event_name == 'release' && github.event.release.draft == false }} | |
run: | | |
sed -i 's/VERSION \= \".*\"/VERSION \= \"${{ github.ref_name }}\"/' ./custom_components/opnsense/const.py | |
- name: Update Changelog | |
if: ${{ github.event_name == 'release' && github.event.release.draft == false && github.event.release.prerelease == false }} | |
uses: rhysd/changelog-from-release/action@v3 | |
with: | |
file: CHANGELOG.md | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
commit: false | |
- name: Commit & Push Version Changes | |
if: ${{ github.event_name == 'release' && github.event.release.draft == false && github.event.release.prerelease == false }} | |
uses: actions-js/push@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.event.release.target_commitish }} | |
message: 'Updating to version ${{ github.ref_name }}' | |
- name: Extract variables from const.py | |
if: ${{ github.event_name == 'release' && github.event.release.draft == false }} | |
id: extract_variables | |
run: | | |
OPNSENSE_LTD_FIRMWARE=$(grep 'OPNSENSE_LTD_FIRMWARE' custom_components/opnsense/const.py | cut -d '"' -f2) | |
OPNSENSE_MIN_FIRMWARE=$(grep 'OPNSENSE_MIN_FIRMWARE' custom_components/opnsense/const.py | cut -d '"' -f2) | |
echo "OPNSENSE_LTD_FIRMWARE=$OPNSENSE_LTD_FIRMWARE" >> $GITHUB_ENV | |
echo "OPNSENSE_MIN_FIRMWARE=$OPNSENSE_MIN_FIRMWARE" >> $GITHUB_ENV | |
- name: Update release notes with firmware information | |
if: ${{ github.event_name == 'release' && github.event.release.draft == false }} | |
run: | | |
echo "Updating release with tag: ${{ github.ref_name }}" | |
gh release edit ${{ github.ref_name }} \ | |
--notes "<h3>OPNsense Minimum Firmware Required: ${{ env.OPNSENSE_MIN_FIRMWARE }}</h3><h4>OPNsense Recommended Firmware: ${{ env.OPNSENSE_LTD_FIRMWARE }}</h4><p>$(gh release view ${{ github.ref_name }} --json body -q .body)<p><i>For firmware versions below the minimum version, the integration will not permit new installations and existing installations will no longer start. Firmware versions below the recommended version will likely work but may have limited features and/or show errors in the logs.</i>" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Zip | |
uses: thedoctor0/[email protected] | |
with: | |
type: 'zip' | |
filename: 'opnsense.zip' | |
directory: ./custom_components/opnsense | |
- name: Upload Zip to Release | |
if: ${{ github.event_name == 'release' && github.event.release.draft == false }} | |
uses: Roang-zero1/[email protected] | |
with: | |
args: ./custom_components/opnsense/opnsense.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Add Zip to Action | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
uses: actions/[email protected] | |
with: | |
name: opnsense | |
path: ./custom_components/opnsense/opnsense.zip | |
if-no-files-found: error |