|
1 | 1 | name: Create Release Tags |
2 | 2 |
|
3 | | -# This workflow automatically creates and pushes release tags when manually triggered |
4 | | -# It's designed to make the action ready for use in other repositories |
| 3 | +# This workflow creates and pushes release tags for every commit to main, |
| 4 | +# and also supports manual tagging via workflow_dispatch. |
5 | 5 |
|
6 | 6 | on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
7 | 10 | workflow_dispatch: |
8 | 11 | inputs: |
9 | 12 | version: |
10 | | - description: 'Version number (e.g., 1.0.0)' |
11 | | - required: true |
| 13 | + description: 'Version number (e.g., 1.0.0). Leave empty to auto-generate.' |
| 14 | + required: false |
12 | 15 | type: string |
13 | 16 | create_release: |
14 | 17 | description: 'Create GitHub Release' |
|
31 | 34 |
|
32 | 35 | - name: Validate version format |
33 | 36 | run: | |
34 | | - VERSION="${{ github.event.inputs.version }}" |
| 37 | + INPUT_VERSION="${{ github.event.inputs.version }}" |
| 38 | + if [ -n "${INPUT_VERSION:-}" ]; then |
| 39 | + VERSION="$INPUT_VERSION" |
| 40 | + else |
| 41 | + VERSION="1.0.${{ github.run_number }}" |
| 42 | + fi |
35 | 43 | if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
36 | 44 | echo "Error: Version must be in semver format (e.g., 1.0.0)" |
37 | 45 | exit 1 |
|
53 | 61 | - name: Create semantic version tag |
54 | 62 | run: | |
55 | 63 | echo "Creating tag ${FULL_VERSION}..." |
| 64 | + if git rev-parse "$FULL_VERSION" >/dev/null 2>&1; then |
| 65 | + echo "Tag ${FULL_VERSION} already exists; skipping." |
| 66 | + exit 0 |
| 67 | + fi |
56 | 68 | git tag -a "$FULL_VERSION" -m "${FULL_VERSION} - Release of ProverCoderAI Release Action" |
57 | 69 | git push origin "$FULL_VERSION" |
58 | 70 |
|
|
76 | 88 | echo " - uses: ProverCoderAI/action-release@${FULL_VERSION}" |
77 | 89 |
|
78 | 90 | - name: Create GitHub Release |
79 | | - if: github.event.inputs.create_release == 'true' |
| 91 | + if: github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true' |
80 | 92 | uses: softprops/action-gh-release@v2 |
81 | 93 | with: |
82 | 94 | tag_name: ${{ env.FULL_VERSION }} |
|
0 commit comments