-
Notifications
You must be signed in to change notification settings - Fork 8
46 lines (39 loc) · 1.35 KB
/
publish.yaml
File metadata and controls
46 lines (39 loc) · 1.35 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
name: Generate and Publish Manifest
on:
push:
tags: [ 'v*' ]
pull_request:
types: [closed]
branches: [main, master]
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
if: github.event_name == 'push' || (github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Release v'))
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Extract version from tag
if: github.event_name == 'push'
run: |
VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract version from PR title
if: github.event_name == 'pull_request'
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
VERSION=$(echo "$PR_TITLE" | grep -oP 'Release v\K[0-9]+\.[0-9]+\.[0-9]+')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Validate version
run: |
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format: $VERSION"
exit 1
fi
echo "Publishing version: $VERSION"
- name: Publish manifest and release
uses: version-fox/plugin-manifest-action@main
with:
version: ${{ env.VERSION }}
github-token: ${{ secrets.GITHUB_TOKEN }}