|
| 1 | +# This action shows how to collect version information and propagate it to the next job. |
| 2 | +name: Collect Version Info |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +jobs: |
| 13 | + collect-version-info: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + outputs: |
| 16 | + current_version: ${{ steps.version-info.outputs.current_version }} |
| 17 | + current_major_version: ${{ steps.version-info.outputs.current_major_version }} |
| 18 | + current_minor_version: ${{ steps.version-info.outputs.current_minor_version }} |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v5 |
| 22 | + with: |
| 23 | + fetch-tags: true # in case your version provider is cvs |
| 24 | + - uses: commitizen-tools/setup-cz@main |
| 25 | + - id: version-info |
| 26 | + run: | |
| 27 | + # Gather version information |
| 28 | + current_version="$(cz version -p)" |
| 29 | + current_major_version="$(cz version -p --major)" |
| 30 | + current_minor_version="$(cz version -p --minor)" |
| 31 | +
|
| 32 | + # Set output variables |
| 33 | + echo "current_version=$current_version" >> $GITHUB_OUTPUT |
| 34 | + echo "current_major_version=$current_major_version" >> $GITHUB_OUTPUT |
| 35 | + echo "current_minor_version=$current_minor_version" >> $GITHUB_OUTPUT |
| 36 | + read-version-info: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + needs: collect-version-info |
| 39 | + steps: |
| 40 | + - name: Checkout code |
| 41 | + uses: actions/checkout@v5 |
| 42 | + - run: | |
| 43 | + # Read version information |
| 44 | + current_version="${{ needs.collect-version-info.outputs.current_version }}" |
| 45 | + current_major_version="${{ needs.collect-version-info.outputs.current_major_version }}" |
| 46 | + current_minor_version="${{ needs.collect-version-info.outputs.current_minor_version }}" |
| 47 | +
|
| 48 | + # Print version information |
| 49 | + echo "Current version: $current_version" |
| 50 | + echo "Current major version: $current_major_version" |
| 51 | + echo "Current minor version: $current_minor_version" |
0 commit comments