From 0e4ff7443edaed71900ea26442ecf3ef4f8a4781 Mon Sep 17 00:00:00 2001 From: Eric Severance Date: Mon, 8 May 2023 19:27:22 -0700 Subject: [PATCH] Inline the update js --- .github/update_release_notes.js | 31 ------------------------------- .github/workflows/publish.yml | 23 +++++++++++++++++++---- pyproject.toml | 2 +- 3 files changed, 20 insertions(+), 36 deletions(-) delete mode 100644 .github/update_release_notes.js diff --git a/.github/update_release_notes.js b/.github/update_release_notes.js deleted file mode 100644 index e0708c23..00000000 --- a/.github/update_release_notes.js +++ /dev/null @@ -1,31 +0,0 @@ -// Replace ${VARIABLES} in the RELEASE_NOTES_TEMPLATE.md file. -// Used by .github/workflows/publish.yml. -const fsp = require('fs').promises; - -module.exports = async ({github, context, process}) => { - const fileOpts = { encoding: 'utf8' }; - let template = await fsp.readFile(process.env.TEMPLATE_FILE, fileOpts); - for (const [key, value] of Object.entries(process.env)) { - template = template.replaceAll(`\${${key}}`, value); - } - - let hashes = await fsp.readFile(process.env.SHA256SUM_TXT, fileOpts); - hashes = hashes.trim() - template = template.replace('${SHA256SUM}', hashes); - - const release = await github.rest.repos.getReleaseByTag({ - ...context.repo, - tag: process.env.GITHUB_REF_NAME, - }); - const body = (release.body || '').trim(); - - if (body.includes(hashes)) { - throw new Error('The release template has already been applied.'); - } - - return await github.rest.repos.updateRelease({ - ...context.repo, - release_id: release.id, - body: template.replace('${BODY}', body), - }); -} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bcd7d209..4d1f3e24 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -108,16 +108,31 @@ jobs: ./hashes/* \ ./${{ needs.slsa.outputs.provenance-name }}/*.intoto.jsonl \ ./signing-artifacts-sigstore/*/*.sigstore + - name: Add SHA256SUM environment variable + run: | + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + echo "SHA256SUM<<$EOF" >> "$GITHUB_ENV" + cat ./hashes/*.sha256sum.txt >> "$GITHUB_ENV" + echo "$EOF" >> "$GITHUB_ENV" - name: Update release text env: + BODY: ${{ github.event.release.body || '' }} + RELEASE_ID: ${{ github.event.release.id }} TEMPLATE_FILE: ./.github/RELEASE_NOTES_TEMPLATE.md - SHA256SUM_TXT: ./hashes/pywemo-${{ needs.build.outputs.version }}.sha256sum.txt uses: actions/github-script@v6 with: script: | - const update = require('./.github/update_release_notes.js') - const result = await update({github, context, process}); - console.log(result); + const fsp = require('fs').promises; + let template = await fsp.readFile(process.env.TEMPLATE_FILE, { encoding: 'utf8' }); + for (const [key, value] of Object.entries(process.env)) { + template = template.replaceAll(`\${${key}}`, value); + } + + await github.rest.repos.updateRelease({ + ...context.repo, + release_id: process.env.RELEASE_ID, + body: template.replace('${BODY}', body), + }); pypi: name: Publish to PyPi diff --git a/pyproject.toml b/pyproject.toml index 3accf7ad..c48e4910 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "pywemo-esev" -version = "0.9.1rc17" +version = "0.9.1rc18" description = "Lightweight Python module to discover and control WeMo devices" authors = ["Eric Severance "] license = "MIT"