Skip to content

Commit

Permalink
Allow name and prerelease determining variables to be picked up by cr…
Browse files Browse the repository at this point in the history
…eate release step
  • Loading branch information
mksanger committed Jan 18, 2024
1 parent 3a8adef commit ea0e78d
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,32 @@ jobs:
release_variables:
runs-on: ubuntu-latest

defaults:
run:
shell: bash -l -e -o pipefail {0}

steps:
- name: "Checkout code"
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "Fetch Tags"
# Workaround for https://github.com/actions/checkout/issues/290
run: |
# Avoid git exiting when Actions runs
git config --global --add safe.directory "$PWD"
git fetch --tags --force
- name: "Get release variables"
run: |
echo 'RELEASE_VERSION='$(git describe --always --tags) >> $GITHUB_ENV
echo 'MASTER_SHA='$(git rev-parse origin/master) >> $GITHUB_ENV
outputs:
isRelease: ${{ github.sha == env.MASTER_SHA }}
releaseVersion: ${{ env.RELEASE_VERSION }}

deploy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -107,12 +125,12 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: client_bundle
path: $BUNDLE_NAME
path: ${{ env.BUNDLE_NAME }}

release:
runs-on: ubuntu-latest

needs: bundle
needs: [release_variables, bundle]

if: always()

Expand All @@ -121,18 +139,6 @@ jobs:
shell: bash -l -e -o pipefail {0}

steps:
- name: "Checkout code"
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "Fetch Tags"
# Workaround for https://github.com/actions/checkout/issues/290
run: |
# Avoid git exiting when Actions runs
git config --global --add safe.directory "$PWD"
git fetch --tags --force

- name: "Download artifact"
uses: actions/download-artifact@v3
Expand All @@ -142,9 +148,12 @@ jobs:
- name: "Create Release"
uses: ncipollo/release-action@v1.12.0
with:
name: ${{ env.RELEASE_VERSION }}
prerelease: ${{ !(github.sha == env.MASTER_SHA) }}
artifacts: BUNDLE_NAME
name: ${{ env.NAME }}
prerelease: ${{ env.PRERELEASE }}
artifacts: ${{ env.BUNDLE_NAME }}
removeArtifacts: true
artifactErrorsFailBuild: true
generateReleaseNotes: true
env:
NAME: ${{ needs.release_variables.outputs.releaseVersion }}
PRERELEASE: ${{ !needs.release_variables.outputs.isRelease }}

0 comments on commit ea0e78d

Please sign in to comment.