Skip to content

Commit

Permalink
Improve release script and workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0der committed Jun 21, 2021
1 parent 6d70921 commit a98028a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
MONGO_USERNAME: ${{ secrets.MONGO_USERNAME }}
MONGO_PASSWORD: ${{ secrets.MONGO_PASSWORD }}
SHORT_HASH: ${{ steps.var.outputs.sha_short }}
run: bin/release-binary.sh "master" "$SHORT_HASH" "$MONGO_URL" "$MONGO_USERNAME" "$MONGO_PASSWORD"
run: bin/release-binary.sh "$MONGO_URL" "$MONGO_USERNAME" "$MONGO_PASSWORD" "$SHORT_HASH" "master"
17 changes: 16 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ on:
- '*'
jobs:
build:
name: "Stable Release"
runs-on: ubuntu-latest
environment: production
services:
mongodb:
image: mongo:3.2
ports:
- 27017:27017
steps:
- uses: actions/checkout@v2
- name: Run tests
Expand All @@ -15,7 +22,15 @@ jobs:
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Build artifacts
run: ./gradlew -Penv=production -Prelease=${{ steps.var.outputs.tag }} clean assemble
- uses: ncipollo/release-action@v1
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: "build/distributions/sdkman-cli-*.zip"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update MongoDB
env:
MONGO_URL: ${{ secrets.MONGO_URL }}
MONGO_USERNAME: ${{ secrets.MONGO_USERNAME }}
MONGO_PASSWORD: ${{ secrets.MONGO_PASSWORD }}
RELEASE_TAG: ${{ steps.var.outputs.tag }}
run: bin/release-binary.sh "$MONGO_URL" "$MONGO_USERNAME" "$MONGO_PASSWORD" "$RELEASE_TAG" "stable"
23 changes: 12 additions & 11 deletions bin/release-binary.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#!/usr/bin/env bash

BRANCH="$1"
SHORT_HASH="$2"
MONGO_URL="$3"
MONGO_USERNAME="$4"
MONGO_PASSWORD="$5"
VERSION="$BRANCH+$SHORT_HASH"
MONGO_URL="$1"
MONGO_USERNAME="$2"
MONGO_PASSWORD="$3"
PARAM_1="$4"
PARAM_2="$5"

echo "Mongo URL: $MONGO_URL"

if [[ -z "$MONGO_USERNAME" || -z "$MONGO_PASSWORD" ]]; then
echo "No mongo credentials so doing nothing..."
return 1
fi

echo "Mongo URL: $MONGO_URL"

if [[ "$BRANCH" == 'master' ]]; then
FIELD="betaCliVersion"
else
if [[ "$PARAM_2" == 'stable' ]]; then
FIELD="stableCliVersion"
VERSION="$PARAM_1"
else
FIELD="betaCliVersion"
VERSION="master+$PARAM_1"
fi

echo "Release: $FIELD as $VERSION"
Expand Down

0 comments on commit a98028a

Please sign in to comment.