Skip to content

Commit

Permalink
SWI-1694: Update deploy to handle pre-releases
Browse files Browse the repository at this point in the history
  • Loading branch information
juliajanu committed Oct 18, 2023
1 parent f09ba23 commit 4ed5833
Showing 1 changed file with 72 additions and 8 deletions.
80 changes: 72 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,83 @@ env:
CSHARP_VERSION: 7.0.x

jobs:
publish:
name: Publish
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' }}
deploy_pre_release:
name: Deploy OpenAPI Generator Client Pre-Release
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'feature/openapi-generator-sdk' }}
runs-on: ubuntu-latest
env:
BW_PROJECT_NAME: src/Bandwidth.Standard
BW_PROJECT_TEST_NAME: src/Bandwidth.Standard.Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
steps:
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV

- name: Check Release Tag Format
run: |
re=[0-9]+\.[0-9]+\.[0-9]+b[0-9]+
if ! [[ $RELEASE_VERSION =~ $re ]]; then
echo 'Tag does not match expected regex pattern for beta releases (v[0-9]+.[0-9]+.[0-9]+b[0-9]+)'
echo $RELEASE_VERSION
echo 'Please update your tag to match the expected regex pattern'
exit 1
fi
- name: Checkout
uses: actions/checkout@v3
with:
ref: feature/openapi-generator-sdk

- name: Setup Dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'

- name: Run integration tests
run: dotnet test $BW_PROJECT_TEST_NAME

- name: Pack NuGet package
run: dotnet pack --configuration Release $BW_PROJECT_NAME -p:PackageVersion=$RELEASE_VERSION

- name: Publish NuGet package
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
NUGET_SOURCE: https://api.nuget.org/v3/index.json
run: dotnet nuget push $BW_PROJECT_NAME/bin/Release/*.nupkg -s $NUGET_SOURCE -k $NUGET_KEY

- name: Notify Slack of build status
uses: Bandwidth/[email protected]
if: always()
with:
job-status: ${{ job.status }}
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel: ${{ secrets.SLACK_CHANNEL }}

deploy:
name: deploy 'main' branch
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' }}
runs-on: ubuntu-latest
env:
BW_PROJECT_NAME: src/Bandwidth.Standard
BW_PROJECT_TEST_NAME: src/Bandwidth.Standard.Test
steps:
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV

- name: Check Release Tag Format
run: |
re=[0-9]+\.[0-9]+\.[0-9]+[0-9]+
if ! [[ $RELEASE_VERSION =~ $re ]]; then
echo 'Tag does not match expected regex pattern for beta releases (v[0-9]+.[0-9]+.[0-9]+[0-9]+)'
echo $RELEASE_VERSION
echo 'Please update your tag to match the expected regex pattern'
exit 1
fi
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-dotnet@v1
- name: Setup Dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'

Expand All @@ -53,7 +116,8 @@ jobs:
NUGET_SOURCE: https://api.nuget.org/v3/index.json
run: dotnet nuget push $BW_PROJECT_NAME/bin/Release/*.nupkg -s $NUGET_SOURCE -k $NUGET_KEY

- uses: Bandwidth/[email protected]
- name: Notify Slack of build status
uses: Bandwidth/[email protected]
if: always()
with:
job-status: ${{ job.status }}
Expand Down

0 comments on commit 4ed5833

Please sign in to comment.