Skip to content

Merge branch 'master' into 198-represent-humidifiers-by-humidifier-en… #24

Merge branch 'master' into 198-represent-humidifiers-by-humidifier-en…

Merge branch 'master' into 198-represent-humidifiers-by-humidifier-en… #24

Workflow file for this run

name: Update manifest.json and Prepare Release
on:
push:
tags:
- 'v*' # Trigger on tags that match version patterns like v1.0.0
jobs:
update-manifest:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
# Extract the release version from the tag name
- name: Get Release Version
id: get_version
run: echo "release_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
# Update the manifest.json file with the release version
- name: Update manifest.json
run: |
version=${{ env.release_version }}
jq --arg version "$version" '.version = $version' ./custom_components/philips_airpurifier_coap/manifest.json > temp.json
mv temp.json ./custom_components/philips_airpurifier_coap/manifest.json
# Commit and push changes
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "kongo09"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add ./custom_components/philips_airpurifier_coap/manifest.json
git commit -m "Update manifest.json to version ${{ env.release_version }}"
git push origin :refs/tags/${{ github.ref_name }}
git tag -fa ${{ github.ref_name }} -m "Update to version ${{ github.ref_name }}"
git push origin ${{ github.ref_name }}
# Update the release
- name: Publish Draft Release
id: publish_release
uses: actions/github-script@v4
with:
script: |
const { data: releases } = await github.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
});
const draftRelease = releases.find(release => release.draft && release.tag_name === process.env.GITHUB_REF_NAME);
if (draftRelease) {
await github.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: draftRelease.id,
draft: false
});
} else {
core.setFailed('No draft release found');
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REF_NAME: ${{ github.ref_name }}