|
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Tag to publish (e.g., v1.2.3)' |
| 11 | + required: true |
| 12 | + type: string |
7 | 13 |
|
8 | 14 | jobs: |
9 | 15 | lint-and-test: |
|
15 | 21 | steps: |
16 | 22 | - name: Checkout code |
17 | 23 | uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + ref: ${{ github.event.inputs.tag || github.ref }} |
18 | 26 |
|
19 | 27 | # Backend setup |
20 | 28 | - name: Set up Go |
@@ -79,11 +87,18 @@ jobs: |
79 | 87 | steps: |
80 | 88 | - name: Checkout code |
81 | 89 | uses: actions/checkout@v4 |
| 90 | + with: |
| 91 | + ref: ${{ github.event.inputs.tag || github.ref }} |
82 | 92 |
|
83 | 93 | - name: Extract version from tag |
84 | 94 | id: version |
85 | 95 | run: | |
86 | | - VERSION=${GITHUB_REF#refs/tags/v} |
| 96 | + if [ -n "${{ github.event.inputs.tag }}" ]; then |
| 97 | + TAG="${{ github.event.inputs.tag }}" |
| 98 | + else |
| 99 | + TAG="${GITHUB_REF#refs/tags/}" |
| 100 | + fi |
| 101 | + VERSION=${TAG#v} |
87 | 102 | echo "version=$VERSION" >> $GITHUB_OUTPUT |
88 | 103 | echo "📦 Building version: $VERSION" |
89 | 104 |
|
@@ -120,23 +135,30 @@ jobs: |
120 | 135 | - name: Extract custom title from tag |
121 | 136 | id: release_title |
122 | 137 | run: | |
| 138 | + if [ -n "${{ github.event.inputs.tag }}" ]; then |
| 139 | + TAG_NAME="${{ github.event.inputs.tag }}" |
| 140 | + else |
| 141 | + TAG_NAME="${{ github.ref_name }}" |
| 142 | + fi |
| 143 | +
|
123 | 144 | # Get tag annotation |
124 | | - TAG_MESSAGE=$(git tag -l --format='%(contents)' ${{ github.ref_name }}) |
| 145 | + TAG_MESSAGE=$(git tag -l --format='%(contents)' "$TAG_NAME") |
125 | 146 |
|
126 | 147 | # Check if tag contains custom title |
127 | 148 | if echo "$TAG_MESSAGE" | grep -q "CUSTOM_TITLE:"; then |
128 | 149 | TITLE=$(echo "$TAG_MESSAGE" | grep "CUSTOM_TITLE:" | sed 's/CUSTOM_TITLE: //') |
129 | 150 | echo "title=$TITLE" >> $GITHUB_OUTPUT |
130 | 151 | echo "has_custom_title=true" >> $GITHUB_OUTPUT |
131 | 152 | else |
132 | | - echo "title=Release ${{ github.ref_name }}" >> $GITHUB_OUTPUT |
| 153 | + echo "title=Release $TAG_NAME" >> $GITHUB_OUTPUT |
133 | 154 | echo "has_custom_title=false" >> $GITHUB_OUTPUT |
134 | 155 | fi |
| 156 | + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT |
135 | 157 |
|
136 | 158 | - name: Create GitHub Release |
137 | 159 | uses: softprops/action-gh-release@v1 |
138 | 160 | with: |
139 | | - tag_name: ${{ github.ref_name }} |
| 161 | + tag_name: ${{ steps.release_title.outputs.tag_name }} |
140 | 162 | name: ${{ steps.release_title.outputs.title }} |
141 | 163 | generate_release_notes: true |
142 | 164 | body: | |
|
0 commit comments