-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (78 loc) · 2.62 KB
/
release.yml
File metadata and controls
94 lines (78 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
tag_name: ${{ steps.get_version.outputs.tag_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version from tag
id: get_version
run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.tag_name }}
name: ${{ steps.get_version.outputs.tag_name }}
body: "Release ${{ steps.get_version.outputs.tag_name }} - Building collection and changelog..."
draft: true
prerelease: ${{ contains(steps.get_version.outputs.tag_name, '-') }}
build-ansible-collection:
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Ansible
run: |
python -m pip install --upgrade pip
pip install ansible
- name: Build Ansible collection
run: ansible-galaxy collection build
- name: Get collection filename
id: collection_file
run: |
COLLECTION_FILE=$(ls devil_imps-devil-*.tar.gz)
echo "filename=$COLLECTION_FILE" >> $GITHUB_OUTPUT
- name: Read changelog content
id: changelog
run: |
if [ -f "CHANGELOG.rst" ]; then
echo "changelog_content<<EOF" >> $GITHUB_OUTPUT
cat CHANGELOG.rst >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "changelog_content=No changelog available" >> $GITHUB_OUTPUT
fi
- name: Upload collection and changelog to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.create-release.outputs.tag_name }}
draft: false
body: |
## Release ${{ needs.create-release.outputs.tag_name }}
### Changelog
```
${{ steps.changelog.outputs.changelog_content }}
```
### Files
- **Collection**: `${{ steps.collection_file.outputs.filename }}`
- **Changelog**: `CHANGELOG.rst`
files: |
${{ steps.collection_file.outputs.filename }}
CHANGELOG.rst