Skip to content

Commit

Permalink
add release workflow (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Y committed Aug 22, 2024
1 parent 901e018 commit 3f3d5d7
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 51 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
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
import os
with open('galaxy.yml', 'r') as file:
data = yaml.safe_load(file)
with open(os.environ['GITHUB_OUTPUT'], 'a') as output_file:
output_file.write(f"value={data['version']}\n")
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 "value=true" >> $GITHUB_OUTPUT
else
echo "value=false" >> $GITHUB_OUTPUT
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

# 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"

0 comments on commit 3f3d5d7

Please sign in to comment.