From 7fce8bbc0577a8a9b8c2dc1ce345ec770b173723 Mon Sep 17 00:00:00 2001 From: Artur Y <10753921+artyorsh@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:32:00 +0200 Subject: [PATCH] add release workflow (#5) --- .github/workflows/release.yml | 70 +++++++++++++++++++++++++++++++++++ README.md | 1 + galaxy.yml | 66 ++++++++------------------------- meta/runtime.yml | 2 + 4 files changed, 88 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 meta/runtime.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d2fd338 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,70 @@ +--- +name: "Release" + +on: + push: + branches: + - "master" + +permissions: + contents: "write" + +jobs: + + check_version_update: + runs-on: "ubuntu-latest" + + outputs: + version: ${{ steps.galaxy_yml_version.outputs.value }} + is_updated: ${{ steps.compare_versions.outputs.value }} + + steps: + - uses: "actions/checkout@v4" + + - name: "Install PyYAML" + run: pip install pyyaml + + - name: "Read version from galaxy.yml" + id: galaxy_yml_version + run: | + import yaml + with open('galaxy.yml', 'r') as file: + data = yaml.safe_load(file) + print(f"version={data['version']}") + print(f"::set-output name=value::{data['version']}") + shell: "python" + + - name: "Compare with latest git tag" + id: compare_versions + run: | + latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo 'v0.0.0') + + if [[ "${{ steps.galaxy_yml_version.outputs.value }}" != "$latest_tag" ]]; then + echo "::set-output name=value::true" + else + echo "::set-output name=value::false" + fi + + publish: + runs-on: "ubuntu-latest" + needs: check_version_update + if: needs.check_version_update.outputs.is_updated == 'true' + + steps: + - uses: "actions/checkout@v4" + + - name: "Build the Collection" + run: ansible-galaxy collection build + + - name: "Publish to Galaxy" + run: >- + ansible-galaxy collection publish + --api-key ${{ secrets.GALAXY_API_KEY }} + ./artyorsh-smarthome-${{ needs.check_version_update.outputs.version }}.tar.gz + + - name: "Publish a new tag" + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git tag ${{ needs.check_version_update.outputs.version }} + git push origin ${{ needs.check_version_update.outputs.version }} diff --git a/README.md b/README.md index d20c08b..5002d9f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Test (Ubuntu 22.04)](https://github.com/artyorsh/ansible-collection-smarthome/actions/workflows/test-ubuntu-lts.yml/badge.svg?event=push)](https://github.com/artyorsh/ansible-collection-smarthome/actions/workflows/test-ubuntu-lts.yml) +[![Ansible Galaxy](https://img.shields.io/badge/collection-artyorsh.smarthome-blue)](https://galaxy.ansible.com/artyorsh/smarthome) ## License diff --git a/galaxy.yml b/galaxy.yml index 8fbf4f9..f19efac 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,69 +1,33 @@ --- -### REQUIRED -# The namespace of the collection. This can be a company/brand/organization or product namespace under which all -# content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with -# underscores or numbers and cannot contain consecutive underscores namespace: artyorsh -# The name of the collection. Has the same character restrictions as 'namespace' name: smarthome -# The version of the collection. Must be compatible with semantic versioning -version: 1.0.0 +version: 1.0.0-dev -# The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md -# A list of the collection's content authors. Can be just the name or in the format 'Full Name (url) -# @nicks:irc/im.site#channel' authors: - - your name + - artyorsh - -### OPTIONAL but strongly recommended -# A short summary description of the collection description: your collection description -# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only -# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file' license: - - GPL-2.0-or-later - -# The path to the license file for the collection. This path is relative to the root of the collection. This key is -# mutually exclusive with 'license' -license_file: '' - -# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character -# requirements as 'namespace' and 'name' -tags: [] + - MIT -# Collections that this collection requires to be installed for it to be usable. The key of the dict is the -# collection label 'namespace.name'. The value is a version range -# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version -# range specifiers can be set and are separated by ',' -dependencies: {} +tags: + - smarthome + - iot + - homeassistant + - zigbee2mqtt + - mosquitto -# The URL of the originating SCM repository -repository: http://example.com/repository +dependencies: + "community.docker": ">=3.0.0" -# The URL to any online docs -documentation: http://docs.example.com +repository: https://github.com/artyorsh/ansible-collection-smarthome +documentation: https://github.com/artyorsh/ansible-collection-smarthome +homepage: https://artyorsh.me +issues: https://github.com/artyorsh/ansible-collection-smarthome/issues -# The URL to the homepage of the collection/project -homepage: http://example.com - -# The URL to the collection issue tracker -issues: http://example.com/issue/tracker - -# A list of file glob-like patterns used to filter any files or directories that should not be included in the build -# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This -# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry', -# and '.git' are always filtered. Mutually exclusive with 'manifest' build_ignore: [] - -# A dict controlling use of manifest directives used in building the collection artifact. The key 'directives' is a -# list of MANIFEST.in style -# L(directives,https://packaging.python.org/en/latest/guides/using-manifest-in/#manifest-in-commands). The key -# 'omit_default_directives' is a boolean that controls whether the default directives are used. Mutually exclusive -# with 'build_ignore' -# manifest: null diff --git a/meta/runtime.yml b/meta/runtime.yml new file mode 100644 index 0000000..b1198d7 --- /dev/null +++ b/meta/runtime.yml @@ -0,0 +1,2 @@ +--- +requires_ansible: ">=2.17.3"