forked from cowrie/cowrie
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (96 loc) · 3.58 KB
/
weekly-release.yml
File metadata and controls
115 lines (96 loc) · 3.58 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# ABOUTME: Automated weekly release workflow that creates a new patch version
# ABOUTME: if there have been commits since the last release.
---
name: Weekly Release
on: # yamllint disable-line rule:truthy
schedule:
# Run every Monday at 09:00 UTC
- cron: '0 9 * * 1'
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (do not create release)'
required: false
default: 'false'
type: boolean
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
jobs:
test:
uses: ./.github/workflows/tox.yml
weekly-release:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get latest release tag
id: latest_tag
run: |
# Get the latest tag matching vX.Y.Z pattern
LATEST_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n1)
echo "tag=${LATEST_TAG}" >> $GITHUB_OUTPUT
echo "Latest tag: ${LATEST_TAG}"
- name: Check for changes since last release
id: changes
run: |
LATEST_TAG="${{ steps.latest_tag.outputs.tag }}"
if [ -z "$LATEST_TAG" ]; then
echo "No previous release tag found"
echo "has_changes=true" >> $GITHUB_OUTPUT
exit 0
fi
# Count commits since the last tag
COMMIT_COUNT=$(git rev-list --count "${LATEST_TAG}..HEAD")
echo "Commits since ${LATEST_TAG}: ${COMMIT_COUNT}"
if [ "$COMMIT_COUNT" -gt 0 ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Calculate next version
id: next_version
if: steps.changes.outputs.has_changes == 'true'
run: |
LATEST_TAG="${{ steps.latest_tag.outputs.tag }}"
if [ -z "$LATEST_TAG" ]; then
# No previous tag, start at v0.0.1
NEXT_VERSION="v0.0.1"
else
# Parse version components (remove 'v' prefix)
VERSION="${LATEST_TAG#v}"
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
# Increment patch version
NEXT_PATCH=$((PATCH + 1))
NEXT_VERSION="v${MAJOR}.${MINOR}.${NEXT_PATCH}"
fi
echo "next_version=${NEXT_VERSION}" >> $GITHUB_OUTPUT
echo "Next version: ${NEXT_VERSION}"
- name: Create release
if: steps.changes.outputs.has_changes == 'true' && inputs.dry_run != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
NEXT_VERSION="${{ steps.next_version.outputs.next_version }}"
LATEST_TAG="${{ steps.latest_tag.outputs.tag }}"
echo "Creating release ${NEXT_VERSION}"
# Create release with auto-generated notes
gh release create "${NEXT_VERSION}" \
--title "${NEXT_VERSION}" \
--generate-notes \
--notes-start-tag "${LATEST_TAG}"
- name: Dry run summary
if: steps.changes.outputs.has_changes == 'true' && inputs.dry_run == 'true'
run: |
echo "Dry run - would have created release: ${{ steps.next_version.outputs.next_version }}"
- name: No changes summary
if: steps.changes.outputs.has_changes != 'true'
run: |
echo "No changes since last release (${{ steps.latest_tag.outputs.tag }}). Skipping release."