Skip to content

Commit

Permalink
update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Matchlighter committed Feb 3, 2024
1 parent b12e1a9 commit 6795587
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 36 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/auto_release.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Publish Images
name: Publish Images and Release

# yamllint disable-line rule:truthy
on:
Expand Down Expand Up @@ -67,10 +67,25 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

with:
diff-search: true
token: ${{ secrets.GITHUB_TOKEN }}

# You can use this to make the action use the current version (either from the
# local file or the provided URL, see the `file-url` option) as either the added
# or deleted version.
# Accepted values are 'new' (if you want that version to be the "added" one) and
# 'old' (to make it the "deleted" one).
# Default: ''
# assume-same-version: old

- name: Generate short tags
id: tags
run: |
script/generate_tags.py
script/generate_tags.py --package-version ${{ steps.check.outputs.version }} --package-version-changed ${{ steps.check.outputs.changed }}
# --suffix "${{ matrix.image.suffix }}"

- name: Build and push
Expand All @@ -91,10 +106,38 @@ jobs:
BUILD_VERSION=${{ steps.tags.outputs.version }}
BUILD_CHANNEL=${{ steps.tags.outputs.channel }}
outputs:
version: ${{ steps.tags.outputs.version }}
channel: ${{ steps.tags.outputs.channel }}

create-release:
if: github.repository == 'matchlighter/typedaemon' && github.event_name != 'release' && needs.deploy-docker.outputs.channel == 'release'
needs: [deploy-docker]
permissions:
contents: write
packages: write
runs-on: ubuntu-latest
steps:
- name: "Generate changelog"
id: changelog
uses: heinrichreimer/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.changelog.outputs.changelog }}
tag_name: ${{ needs.deploy-docker.outputs.version }}
target_commitish: ${{ github.ref }}

outputs:
body: ${{ steps.changelog.outputs.changelog }}

deploy-ha-addon-repo:
if: github.repository == 'matchlighter/typedaemon' && github.event_name == 'release'
if: ${{ !failure() && github.repository == 'matchlighter/typedaemon' && needs.deploy-docker.outputs.channel == 'release' }}
runs-on: ubuntu-latest
needs: [deploy-docker]
needs: [deploy-docker, create-release]
steps:
- name: Trigger Workflow
uses: actions/github-script@v6
Expand All @@ -107,7 +150,7 @@ jobs:
workflow_id: "bump-version.yml",
ref: "master",
inputs: {
version: "${{ github.event.release.tag_name }}",
content: ${{ toJSON(github.event.release.body) }}
version: "${{ needs.deploy-docker.outputs.version }}",
content: ${{ toJSON(github.event.release.body || needs.create-release.outputs.body) }}
}
})
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.2",
"version": "0.3.3",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
28 changes: 25 additions & 3 deletions script/generate_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,35 @@
required=False,
help="The suffix of the tag.",
)
parser.add_argument(
"--package-version",
type=str,
required=False,
)
parser.add_argument(
"--package-version-changed",
type=str,
required=False,
)


def package_json_version_changed():
pass

def main():
args = parser.parse_args()

channel = CHANNEL_DEV
version = ""
major_minor_version = None
tags_to_push = []
if os.environ.get("GITHUB_EVENT_NAME", None) == "release":
version = os.environ.get("GITHUB_REF").replace("refs/tags/", "")

branch = os.environ.get("GITHUB_REF", "arbitrary").replace("refs/heads/", "")

def set_version(v):
nonlocal version, channel, major_minor_version

version = v
tags_to_push.append(version)

# detect channel from tag
Expand All @@ -39,8 +57,12 @@ def main():
channel = CHANNEL_RELEASE
else:
channel = CHANNEL_BETA

if os.environ.get("GITHUB_EVENT_NAME", None) == "release":
set_version(os.environ.get("GITHUB_REF").replace("refs/tags/", ""))
elif branch == "master" and args.package_version_changed == "true":
set_version(args.package_version)
else:
branch = os.environ.get("GITHUB_REF", "arbitrary").replace("refs/heads/", "")
sha = os.environ.get("GITHUB_SHA", "")
datecode = datetime.datetime.now().isoformat()
version = f"{branch}-{sha}-{datecode}"
Expand Down

0 comments on commit 6795587

Please sign in to comment.