Merge pull request #26 from gardar/ci/changelog

feat: semantic releases and automatic changelog.
This commit is contained in:
Ben Kochie 2023-02-23 18:22:07 +01:00 committed by GitHub
commit 4c2d82f8bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 282 additions and 108 deletions

View file

@ -1,2 +1,4 @@
---
profile: production
warn_list:
- galaxy[version-incorrect] # until collection gets bumped to 1.x.x

52
.github/release-drafter.yml vendored Normal file
View file

@ -0,0 +1,52 @@
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
categories:
- title: 'Major Changes'
labels:
- 'major' # c6476b
- title: 'Minor Changes'
labels:
- 'feature' # 006b75
- 'enhancement' # ededed
- 'refactoring'
- title: 'Bugfixes'
labels:
- 'bug' # fbca04
- title: 'Deprecations'
labels:
- 'deprecated' # fef2c0
exclude-labels:
- 'skip-changelog'
- 'duplicate'
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
- 'feature'
- 'enhancement'
- 'refactoring'
patch:
labels:
- 'patch'
- 'bug'
- 'deprecated'
default: patch
autolabeler:
- label: 'skip-changelog'
title: '/chore/i'
- label: 'bug'
title: '/fix/i'
- label: 'enhancement'
title: '/(enhance|improve)/i'
- label: 'feature'
title: '/feature/i'
- label: 'dreprecated'
title: '/deprecat/i'
change-template: '* $TITLE by @$AUTHOR in #$NUMBER'
template: |
What's Changed
===
$CHANGES

4
.github/version-drafter.yml vendored Normal file
View file

@ -0,0 +1,4 @@
---
major-labels: ['semver:major', 'major', 'breaking']
minor-labels: ['semver:minor', 'minor', 'enhancement', 'deprecated', 'removed', 'security']
patch-labels: ['semver:patch', 'bug', 'trivial', 'bugfix']

View file

@ -1,9 +1,19 @@
---
name: Ansible CI
on: [push, pull_request]
on:
push:
branches-ignore:
- main
pull_request:
types:
- '!closed'
workflow_dispatch:
env:
ANSIBLE_FORCE_COLOR: true
ANSIBLE_GALAXY_SERVER_GALAXY_URL: "https://galaxy.ansible.com"
ANSIBLE_GALAXY_SERVER_GALAXY_TIMEOUT: 120
ANSIBLE_GALAXY_SERVER_LIST: "galaxy"
jobs:
ansible-lint:

View file

@ -0,0 +1,40 @@
---
on:
pull_request:
types: [opened, edited, synchronize, reopened]
name: Auto label pull request
jobs:
label:
runs-on: ubuntu-latest
steps:
- name: "Confirm correct pull request title"
uses: deepakputhraya/action-pr-title@master
with:
allowed_prefixes: 'feat,feature,fix,major,breaking,minor,enhancement,deprecated,removed,security,bug,bugfix,docs,packaging,test,refactor,refactoring,skip-release,skip_changelog'
- name: "Apply label"
if: github.event.pull_request.labels.length == 0
uses: bcoe/conventional-release-labels@v1
with:
type_labels: |
{
"feature": "enhancement",
"feat": "enhancement",
"fix": "bugfix",
"major": "major",
"breaking": "breaking",
"minor": "minor",
"enhancement": "enhancement",
"deprecated": "deprecated",
"removed": "removed",
"security": "security",
"bug": "bug",
"bugfix": "bugfix",
"docs": "trivial",
"packaging": "trivial",
"test": "trivial",
"refactor": "trivial",
"refactoring": "trivial",
"skip-release": "skip_changelog",
"skip_changelog": "skip_changelog"
}

27
.github/workflows/publish.yml vendored Normal file
View file

@ -0,0 +1,27 @@
---
name: Ansible collection publish
on:
push:
tags:
- '*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Install tools"
run: "python -m pip install ansible-base --disable-pip-version-check"
- name: "Build the collection"
run: ansible-galaxy collection build
- name: "Upload built collection to release"
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: prometheus-prometheus-*.tar.gz
file_glob: true
tag: ${{ github.ref }}
overwrite: true

View file

@ -1,89 +0,0 @@
name: Publish Collection
on:
push:
branches:
- main
release:
types:
- 'published'
env:
python-version: 3.9
jobs:
publish-latest:
if: github.event_name == 'push'
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ansible_collections/prometheus/prometheus
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: ansible_collections/prometheus/prometheus
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ env.python-version }}
- name: Install ansible-base (devel)
run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
- name: Build the collection
run: ansible-galaxy collection build
- name: Rename the build artifact
run: mv prometheus-prometheus-*.tar.gz prometheus-community-prometheus-latest.tar.gz
# Moving the tag leaves an orphan artifact. Just changing the artifact doesn't move the tag.
- name: Delete latest tag and release
uses: dev-drprasad/delete-tag-and-release@v0.1.2
with:
delete_release: true
tag_name: latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload files to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ansible_collections/prometheus/prometheus/prometheus-community-prometheus-latest.tar.gz
asset_name: prometheus-community-prometheus-latest.tar.gz
body: "Development release"
tag: latest
overwrite: true
publish-tagged:
if: github.event_name == 'release'
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ansible_collections/prometheus/prometheus
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: ansible_collections/prometheus/prometheus
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ env.python-version }}
- name: Install ansible-base (devel)
run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
- name: Build the collection
run: ansible-galaxy collection build
- name: Upload files to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ansible_collections/prometheus/prometheus/prometheus-community-prometheus-*.tar.gz
file_glob: true
tag: ${{ github.ref }}
overwrite: true

61
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,61 @@
---
name: Ansible collection release
on:
pull_request:
types:
- closed
jobs:
release:
if: |
github.event.pull_request.merged &&
github.ref == github.event.repository.default_branch &&
!contains(github.event.pull_request.labels.*.name, 'skip_changelog')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Install tools"
run: "python -m pip install ansible-base antsibull-changelog --disable-pip-version-check"
- name: "Calculate next version"
id: version
uses: gardar/version-drafter-action@event-triggers # Until PR gets merged: https://github.com/patrickjahns/version-drafter-action/pull/343
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: "Generate new version in changelog.yaml"
run: antsibull-changelog release -v --version "${{ steps.version.outputs.next-version }}"
- name: "Run antsichaut"
uses: rndmh3ro/antsichaut-action@main
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
since_version: "${{ steps.version.outputs.current-version }}"
- name: "Update Changelog.rst"
run: "antsibull-changelog generate -v"
- name: "Update collection version"
uses: mikefarah/yq@master
with:
cmd: yq -i '.version = "${{ steps.version.outputs.next-version }}"' 'galaxy.yml'
- name: "Write changelog and version"
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.event.pull_request.base.ref }}
commit_message: "chore: update version"
- name: "Checkout updated branch"
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: "Publish release"
id: release-publish
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

14
CHANGELOG.rst Normal file
View file

@ -0,0 +1,14 @@
===================================
Prometheus.Prometheus Release Notes
===================================
.. contents:: Topics
v0.0.1
======
Major Changes
-------------
- Initial Release

View file

@ -25,26 +25,24 @@ To have your code merged, see the expectations listed below.
You can find a well-written guide [here](https://help.github.com/articles/fork-a-repo).
Please follow common commit best-practices. Be explicit, have a short summary, a well-written description and
Please follow conventional commits for best-practices. Be explicit, have a short summary, a well-written description and
references. This is especially important for the merge-request.
Some great guidelines can be found [here](https://wiki.openstack.org/wiki/GitCommitMessages) and
[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message).
Some great guidelines can be found [here](https://www.conventionalcommits.org/).
## Releases
We try to stick to semantic versioning and our releases are automated. Release is created by assigning a keyword (in a
way similar to circle ci keyword [`[ci skip]`](https://docs.travis-ci.com/user/customizing-the-build#Skipping-a-build))
to a commit with merge request. Available keywords are (square brackets are important!):
We try to stick to semantic versioning and our releases are automated. Release is created by assigning [conventional commits](https://www.conventionalcommits.org/)
to PR title. Available keywords are:
* `[patch]`, `[fix]`, `[bugfix]` - for PATCH version release
* `[minor]`, `[feature]`, `[feat]` - for MINOR version release
* `[major]`, `[breaking change]` - for MAJOR version release
* `[patch]`, `[fix]`, `[bug]`, `[bugfix]`, `[test]`, `[refactor]`, `[packaging]`, `[docs]` - for PATCH version release
* `[minor]`, `[enhancement]`, `[feature]`, `[feat]`, `[deprecated]`, `[removed]`, `[security]` - for MINOR version release
* `[major]`, `[breaking]` - for MAJOR version release
## Changelog
This project uses [antsibull-changelog](https://docs.ansible.com/ansible/latest/dev_guide/developing_collections_changelogs.html#generating-changelogs) to generate changelogs.
Changelog is generated automatically during release process and all information is taken from github issues, PRs and
labels.
Changelog is generated automatically during release process and all information is taken from github PRs, commits and labels.
## Expectations

View file

@ -0,0 +1,17 @@
---
objects: {}
plugins:
become: {}
cache: {}
callback: {}
cliconf: {}
connection: {}
httpapi: {}
inventory: {}
lookup: {}
module: {}
netconf: {}
shell: {}
strategy: {}
vars: {}
version: 0.0.1

View file

@ -0,0 +1,8 @@
---
ancestor:
releases:
0.0.1:
changes:
major_changes:
- 'Initial Release'
release_date: '2023-02-17'

33
changelogs/config.yaml Normal file
View file

@ -0,0 +1,33 @@
---
changelog_filename_template: ../CHANGELOG.rst
changelog_filename_version_depth: 0
changes_file: changelog.yaml
changes_format: combined
ignore_other_fragment_extensions: true
keep_fragments: false
mention_ancestor: true
new_plugins_after_name: removed_features
notesdir: fragments
prelude_section_name: release_summary
prelude_section_title: "Release Summary"
sanitize_changelog: true
sections:
- - major_changes
- "Major Changes"
- - minor_changes
- "Minor Changes"
- - breaking_changes
- "Breaking Changes / Porting Guide"
- - deprecated_features
- "Deprecated Features"
- - removed_features
- "Removed Features (previously deprecated)"
- - security_fixes
- "Security Fixes"
- - bugfixes
- "Bugfixes"
- - known_issues
- "Known Issues"
title: Prometheus.Prometheus
trivial_section_name: trivial
use_fqcn: true

View file

@ -1,13 +1,11 @@
---
namespace: prometheus
name: prometheus
version: 1.0.0
version: 0.0.1
readme: README.md
authors:
- "Ben Kochie (https://github.com/SuperQ)"
- "Paweł Krupa (https://github.com/paulfantom)"
description: "Ansible Collection for Prometheus"
license_file: LICENSE
tags:
@ -19,16 +17,13 @@ tags:
- alerts
- alerting
- cloud
dependencies:
community.crypto: '>=2.0.0'
community.general: '>=1.0.0'
repository: "https://github.com/prometheus-community/ansible"
documentation: "https://github.com/prometheus-community/ansible/blob/main/docs"
homepage: "https://prometheus.io"
issues: "https://github.com/prometheus-community/ansible/issues"
build_ignore:
- 'tests/*'
- '*.tar.gz'

View file

@ -1,3 +1,5 @@
antsibull-changelog
antsichaut
molecule
docker
ansible-lint