Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add release workflow #5

Merged
merged 25 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
name: "Release"

on:

Check warning on line 4 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / lint

4:1 [truthy] truthy value should be one of [false, true]
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 }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
66 changes: 15 additions & 51 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -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 <email> (url)
# @nicks:irc/im.site#channel'
authors:
- your name <[email protected]>
- artyorsh


### OPTIONAL but strongly recommended
# A short summary description of the collection
description: your collection description
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO in #1


# 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
2 changes: 2 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
requires_ansible: ">=2.17.3"
Loading