Skip to content

Commit

Permalink
ci: improve changelog generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Matchlighter committed Feb 4, 2024
1 parent 6795587 commit f3af757
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 150 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ test_setup/
experiments/
dist/
.git/
.github/
.gitignore
Dockerfile
60 changes: 48 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
# target: "lint"
# baseimg: "docker"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -69,7 +69,6 @@ jobs:

- id: check
uses: EndBug/version-check@v2

with:
diff-search: true
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -115,42 +114,79 @@ jobs:
needs: [deploy-docker]
permissions:
contents: write
packages: write
runs-on: ubuntu-latest
steps:
- name: "Generate changelog"
id: changelog
uses: heinrichreimer/[email protected]
- uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: Generate Release Message
id: message
uses: actions/github-script@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }}
script: |
const last_release_resp = await github.rest.repos.getLatestRelease({
owner: "matchlighter",
repo: "typedaemon",
});
const last_release = last_release_resp?.data;
const diff = last_release ? `refs/tags/${last_release.tag_name}..HEAD` : "";
let message = '';
await exec.exec(`git log ${diff} --pretty=format:"- %h %s"`, {
listeners: {
stdout: (data) => { message += data.toString(); },
}
})
core.setOutput("body", message.trim());
- name: Release
id: release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.changelog.outputs.changelog }}
body: ${{ steps.message.outputs.body }}
tag_name: ${{ needs.deploy-docker.outputs.version }}
target_commitish: ${{ github.ref }}
prerelease: ${{ needs.deploy-docker.outputs.channel != 'release' }}

outputs:
body: ${{ steps.changelog.outputs.changelog }}
body: ${{ steps.message.outputs.body }}
release_id: ${{ steps.release.outputs.id }}

deploy-ha-addon-repo:
if: ${{ !failure() && github.repository == 'matchlighter/typedaemon' && needs.deploy-docker.outputs.channel == 'release' }}
runs-on: ubuntu-latest
needs: [deploy-docker, create-release]
steps:
- name: Trigger Workflow
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }}
script: |
github.rest.actions.createWorkflowDispatch({
let content = ${{ toJSON(github.event.release.body) }} || ${{ toJSON(needs.deploy-docker.outputs.body) }};
if (!content) {
const release_resp = await github.rest.repos.getRelease({
owner: "matchlighter",
repo: "typedaemon",
release_id: ${{ needs.create-release.outputs.release_id }},
});
const release = release_resp.data;
console.log(release);
content = release.body;
}
console.log(content);
await github.rest.actions.createWorkflowDispatch({
owner: "matchlighter",
repo: "typedaemon-hassio",
workflow_id: "bump-version.yml",
ref: "master",
inputs: {
version: "${{ needs.deploy-docker.outputs.version }}",
content: ${{ toJSON(github.event.release.body || needs.create-release.outputs.body) }}
content,
}
})
137 changes: 0 additions & 137 deletions hassio.Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typedaemon",
"version": "0.3.3",
"version": "0.3.4",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit f3af757

Please sign in to comment.