-
-
Notifications
You must be signed in to change notification settings - Fork 31
72 lines (65 loc) · 2.54 KB
/
release.yml
File metadata and controls
72 lines (65 loc) · 2.54 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
name: Create Release
on:
workflow_dispatch:
inputs:
package:
description: 'Package to release'
required: true
type: choice
options:
- mcp_dart
- mcp_dart_cli
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write # Required to create tags and releases
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_PAT }}
- name: Set package configuration
id: set-config
run: |
if [ "${{ inputs.package }}" = "mcp_dart" ]; then
echo "working_directory=." >> "$GITHUB_OUTPUT"
echo "tag_prefix=v" >> "$GITHUB_OUTPUT"
else
echo "working_directory=packages/mcp_dart_cli" >> "$GITHUB_OUTPUT"
echo "tag_prefix=mcp_dart_cli-v" >> "$GITHUB_OUTPUT"
fi
- name: Get version from pubspec.yaml
id: get-version
working-directory: ${{ steps.set-config.outputs.working_directory }}
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "📦 Package: ${{ inputs.package }}"
echo "📦 Detected version: $VERSION"
- name: Check if tag already exists
run: |
TAG="${{ steps.set-config.outputs.tag_prefix }}${{ steps.get-version.outputs.version }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "❌ Error: Tag $TAG already exists!"
echo " This version has already been released."
echo " Please bump the version in pubspec.yaml first."
exit 1
fi
echo "✅ Tag $TAG does not exist, proceeding..."
- name: Create and push tag
id: create-tag
run: |
TAG="${{ steps.set-config.outputs.tag_prefix }}${{ steps.get-version.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Release ${{ inputs.package }} ${{ steps.get-version.outputs.version }}"
git push origin "$TAG"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "🏷️ Created and pushed tag: $TAG"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.create-tag.outputs.tag }}
name: ${{ inputs.package }} ${{ steps.get-version.outputs.version }}
generate_release_notes: true
draft: false