|
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + publish: |
| 10 | + description: 'Publish to Conan Center (must be set to "true")' |
| 11 | + required: true |
| 12 | + type: boolean |
| 13 | + default: false |
7 | 14 |
|
8 | 15 | jobs: |
9 | | - publish: |
| 16 | + extract-version: |
10 | 17 | runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + version: ${{ steps.version.outputs.version }} |
| 20 | + tag: ${{ steps.version.outputs.tag }} |
| 21 | + steps: |
| 22 | + - name: Extract version from tag |
| 23 | + id: version |
| 24 | + run: | |
| 25 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 26 | + TAG=${GITHUB_REF#refs/tags/} |
| 27 | + VERSION=${TAG#v} |
| 28 | + else |
| 29 | + # For workflow_dispatch, use the tag input or default |
| 30 | + TAG=${GITHUB_REF#refs/tags/} |
| 31 | + VERSION=${TAG#v} |
| 32 | + fi |
| 33 | + echo "version=${VERSION}" >> $GITHUB_OUTPUT |
| 34 | + echo "tag=${TAG}" >> $GITHUB_OUTPUT |
| 35 | + echo "Tag: ${TAG}, Version: ${VERSION}" |
| 36 | +
|
| 37 | + publish-conan: |
| 38 | + needs: extract-version |
| 39 | + runs-on: ubuntu-latest |
| 40 | + if: | |
| 41 | + (github.event_name == 'workflow_dispatch' && inputs.publish == true) || |
| 42 | + (github.event_name == 'push' && vars.PUBLISH_TO_CONAN == 'true') |
11 | 43 | permissions: |
12 | 44 | contents: write |
13 | 45 | pull-requests: write |
|
18 | 50 | with: |
19 | 51 | fetch-depth: 0 |
20 | 52 |
|
21 | | - - name: Extract version from tag |
22 | | - id: version |
23 | | - run: | |
24 | | - VERSION=${GITHUB_REF#refs/tags/v} |
25 | | - echo "version=${VERSION}" >> $GITHUB_OUTPUT |
26 | | - echo "Tag: ${GITHUB_REF}, Version: ${VERSION}" |
27 | | - |
28 | 53 | - name: Setup Git |
29 | 54 | run: | |
30 | 55 | git config --global user.name "github-actions[bot]" |
|
54 | 79 | CONAN_INDEX_DIR: ${{ github.workspace }}/conan-center-index |
55 | 80 | GITHUB_TOKEN: ${{ secrets.CONAN_INDEX_PAT || secrets.GITHUB_TOKEN }} |
56 | 81 | run: | |
57 | | - ./scripts/publish-conan-version.sh "${{ steps.version.outputs.version }}" |
| 82 | + ./scripts/publish-conan-version.sh "${{ needs.extract-version.outputs.version }}" |
| 83 | +
|
| 84 | + create-release: |
| 85 | + needs: extract-version |
| 86 | + runs-on: ubuntu-latest |
| 87 | + if: github.event_name == 'push' |
| 88 | + permissions: |
| 89 | + contents: write |
| 90 | + |
| 91 | + steps: |
| 92 | + - name: Checkout repository |
| 93 | + uses: actions/checkout@v4 |
| 94 | + with: |
| 95 | + fetch-depth: 0 |
| 96 | + |
| 97 | + - name: Generate release notes |
| 98 | + id: release_notes |
| 99 | + run: | |
| 100 | + TAG="${{ needs.extract-version.outputs.tag }}" |
| 101 | + VERSION="${{ needs.extract-version.outputs.version }}" |
| 102 | + |
| 103 | + # Try to extract release notes from CHANGELOG.md if it exists |
| 104 | + if [ -f CHANGELOG.md ]; then |
| 105 | + # Extract section for this version (format: ## [version] or ## [version] - date) |
| 106 | + # Use awk to extract from the version heading until the next ## heading or --- separator |
| 107 | + RELEASE_NOTES=$(awk -v version="${VERSION}" ' |
| 108 | + BEGIN { in_section = 0 } |
| 109 | + /^## \[/ { |
| 110 | + if (in_section) exit |
| 111 | + if ($0 ~ "\\[" version "\\]") in_section = 1 |
| 112 | + } |
| 113 | + /^---$/ { if (in_section) exit } |
| 114 | + in_section { print } |
| 115 | + ' CHANGELOG.md) |
| 116 | + else |
| 117 | + RELEASE_NOTES="" |
| 118 | + fi |
| 119 | + |
| 120 | + # If no notes found, create a simple one |
| 121 | + if [ -z "$RELEASE_NOTES" ]; then |
| 122 | + RELEASE_NOTES="## Release ${VERSION} |
| 123 | +
|
| 124 | +This release includes the latest changes and improvements." |
| 125 | + fi |
| 126 | + |
| 127 | + # Use multiline output |
| 128 | + echo "notes<<EOF" >> $GITHUB_OUTPUT |
| 129 | + echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT |
| 130 | + echo "EOF" >> $GITHUB_OUTPUT |
| 131 | + |
| 132 | + - name: Create GitHub Release |
| 133 | + uses: softprops/action-gh-release@v1 |
| 134 | + with: |
| 135 | + tag_name: ${{ needs.extract-version.outputs.tag }} |
| 136 | + name: Release ${{ needs.extract-version.outputs.version }} |
| 137 | + body: ${{ steps.release_notes.outputs.notes }} |
| 138 | + draft: false |
| 139 | + prerelease: ${{ contains(needs.extract-version.outputs.version, '-rc') || contains(needs.extract-version.outputs.version, '-alpha') || contains(needs.extract-version.outputs.version, '-beta') }} |
58 | 140 |
|
0 commit comments