-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (107 loc) · 3.65 KB
/
Copy pathrelease.yml
File metadata and controls
122 lines (107 loc) · 3.65 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
116
117
118
119
120
121
122
name: Release (Manual)
on:
workflow_dispatch:
inputs:
bump:
description: Version bump type
required: true
type: choice
options:
- patch
- minor
- major
jobs:
ci:
uses: ./.github/workflows/test.yml
release:
needs: ci
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Harden runner
uses: step-security/harden-runner@v2
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
objects.githubusercontent.com:443
uploads.github.com:443
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Compute next version
id: version
run: |
# Match tags with or without leading 'v'
latest=$(git tag --sort=-version:refname \
| grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' \
| head -1)
latest="${latest:-v0.0.0}"
# Normalise to always have a 'v' prefix for parsing
latest="v${latest#v}"
major=$(printf '%s' "$latest" | cut -d. -f1 | tr -d 'v')
minor=$(printf '%s' "$latest" | cut -d. -f2)
patch=$(printf '%s' "$latest" | cut -d. -f3)
case "${{ inputs.bump }}" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
esac
echo "version=v${major}.${minor}.${patch}" >> "$GITHUB_OUTPUT"
- name: Tag and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "${{ steps.version.outputs.version }}"
git push origin "${{ steps.version.outputs.version }}"
- name: Create GitHub release
run: |
VERSION="${{ steps.version.outputs.version }}"
gh release create "${VERSION}" \
--title "Release ${VERSION}" \
--generate-notes \
--verify-tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
bump-tap:
needs: release
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Harden runner
uses: step-security/harden-runner@v2
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
objects.githubusercontent.com:443
- name: Checkout tap
uses: actions/checkout@v6
with:
repository: 1shooperman/homebrew-tap
token: ${{ secrets.TAP_GITHUB_TOKEN }}
- name: Compute SHA256
id: sha
run: |
VERSION="${{ needs.release.outputs.version }}"
URL="https://github.com/1shooperman/cli-tools/archive/refs/tags/${VERSION}.tar.gz"
SHA=$(curl -sL "$URL" | shasum -a 256 | awk '{print $1}')
echo "sha=${SHA}" >> "$GITHUB_OUTPUT"
echo "url=${URL}" >> "$GITHUB_OUTPUT"
- name: Bump formula
run: |
VERSION="${{ needs.release.outputs.version }}"
sed -i "s|url \".*\"|url \"${{ steps.sha.outputs.url }}\"|" Formula/cli-tools.rb
sed -i "s|sha256 \".*\"|sha256 \"${{ steps.sha.outputs.sha }}\"|" Formula/cli-tools.rb
- name: Push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "chore: bump cli-tools to ${{ needs.release.outputs.version }}"
git push