|
| 1 | +--- |
| 2 | +name: Get and save publish version |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + # Map the workflow outputs to job outputs |
| 7 | + outputs: |
| 8 | + release: |
| 9 | + description: "If the current tag is a release" |
| 10 | + value: ${{ jobs.publish.outputs.release }} |
| 11 | + preRelease: |
| 12 | + description: "If the current tag is a pre-release" |
| 13 | + value: ${{ jobs.publish.outputs.preRelease }} |
| 14 | + version: |
| 15 | + description: "Which version has the tag" |
| 16 | + value: ${{ jobs.publish.outputs.version }} |
| 17 | + |
| 18 | +jobs: |
| 19 | + publish: |
| 20 | + name: Get and save publish version |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + release: ${{ steps.releaseCheck.outputs.release }} |
| 24 | + preRelease: ${{ steps.releaseCheck.outputs.preRelease }} |
| 25 | + version: ${{ steps.getVersion.outputs.version }} |
| 26 | + steps: |
| 27 | + - name: ⬇ Checkout repo |
| 28 | + uses: actions/checkout@v3 |
| 29 | + |
| 30 | + - name: 🔄 Init Cache |
| 31 | + uses: ./.github/actions/npm-cache |
| 32 | + |
| 33 | + - name: 💃🕺 Check if release or prerelease |
| 34 | + id: releaseCheck |
| 35 | + run: | |
| 36 | + chmod +rx ./.github/scripts/get-release.sh |
| 37 | + OUTPUT=$(./.github/scripts/get-release.sh) |
| 38 | + if [[ $OUTPUT == "RELEASE" ]]; |
| 39 | + then |
| 40 | + echo "::set-output name=release::true" |
| 41 | + elif [[ $OUTPUT == "PRE_RELEASE" ]]; |
| 42 | + then |
| 43 | + echo "::set-output name=preRelease::true" |
| 44 | + fi |
| 45 | + env: |
| 46 | + GITHUB_REF: ${{ github.ref }} |
| 47 | + GITHUB_ACTOR: ${{ github.actor }} |
| 48 | + GITHUB_COMMITISH: ${{ github.event.release.target_commitish }} |
| 49 | + GITHUB_PRE_RELEASE: ${{ github.event.release.prerelease }} |
| 50 | + |
| 51 | + - name: ↔ Extract tag name |
| 52 | + shell: bash |
| 53 | + run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/tags/})" |
| 54 | + id: extractTag |
| 55 | + |
| 56 | + - name: 🏷 Get and Set Package Version on Env |
| 57 | + id: getVersion |
| 58 | + env: |
| 59 | + RELEASE: ${{ steps.releaseCheck.outputs.release }} |
| 60 | + PRE_RELEASE: ${{ steps.releaseCheck.outputs.preRelease }} |
| 61 | + TAG: ${{ steps.extractTag.outputs.tag }} |
| 62 | + run: | |
| 63 | + chmod +rx ./.github/scripts/package-version.sh |
| 64 | + OUTPUT=$(./.github/scripts/package-version.sh) |
| 65 | + echo "::set-output name=version::$OUTPUT" |
| 66 | +
|
| 67 | + - name: 🌳 Log Valid Version |
| 68 | + env: |
| 69 | + VALID_SEMVER_VERSION: ${{ steps.getVersion.outputs.version }} |
| 70 | + run: echo "$VALID_SEMVER_VERSION" |
0 commit comments