diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e3a489..077fafa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,7 +66,8 @@ jobs: artifacts: 'bitwarden.sh, run.sh, bitwarden.ps1, - run.ps1' + run.ps1, + version.json' commit: ${{ github.sha }} tag: "v${{ github.event.inputs.release_version }}" name: "Version ${{ github.event.inputs.release_version }}" diff --git a/.github/workflows/update-links.yml b/.github/workflows/update-links.yml index 77eda4d..9c8cb02 100644 --- a/.github/workflows/update-links.yml +++ b/.github/workflows/update-links.yml @@ -36,6 +36,14 @@ jobs: echo "::set-output name=value::$GITHUB_REF_NAME" fi + - name: Update Bitwarden Version Link + uses: bitwarden/gh-actions/update-rebrandly-link@340a677ffb0c53e50ca67cd2c12044cd7f7fc725 + with: + apikey: ${{ steps.retrieve-secrets.outputs.rebrandly-apikey }} + domain: "go.btwrdn.co" + slashtag: "bw-sh-versions" + destination: "https://github.com/bitwarden/self-host/releases/download/${{ steps.tag-name.outputs.value }}/version.json" + - name: Update Bitwarden Script PowerShell Link uses: bitwarden/gh-actions/update-rebrandly-link@340a677ffb0c53e50ca67cd2c12044cd7f7fc725 with: diff --git a/.github/workflows/update-versions.yml b/.github/workflows/update-versions.yml index 9efe2cc..638ccb1 100644 --- a/.github/workflows/update-versions.yml +++ b/.github/workflows/update-versions.yml @@ -33,7 +33,7 @@ jobs: env: LATEST_CORE_VERSION: ${{ steps.get-core.outputs.version }} run: | - CORE_VERSION=$(sed -r -n "s/COREVERSION=\"([0-9]+\.[0-9]+\.[0-9]+)\"/\1/p" bitwarden.sh) + CORE_VERSION=$(grep '^ *"coreVersion":' version.json | awk '{ print $2 }' | sed -e 's/,$//' -e 's/^"//' -e 's/"$//') echo "Core Version: $CORE_VERSION" echo "Latest Core Version: $LATEST_CORE_VERSION" if [ "$CORE_VERSION" != "$LATEST_CORE_VERSION" ]; then @@ -54,7 +54,7 @@ jobs: env: LATEST_WEB_VERSION: ${{ steps.get-web.outputs.version }} run: | - WEB_VERSION=$(sed -r -n "s/WEBVERSION=\"([0-9]+\.[0-9]+\.[0-9]+)\"/\1/p" bitwarden.sh) + WEB_VERSION=$(grep '^ *"webVersion":' version.json | awk '{ print $2 }' | sed -e 's/,$//' -e 's/^"//' -e 's/"$//') echo "Web Version: $WEB_VERSION" echo "Latest Web Version: $LATEST_WEB_VERSION" if [ "$WEB_VERSION" != "$LATEST_WEB_VERSION" ]; then @@ -75,7 +75,7 @@ jobs: env: LATEST_KEY_CONNECTOR_VERSION: ${{ steps.get-key-connector.outputs.version }} run: | - KEY_CONNECTOR_VERSION=$(sed -r -n "s/KEYCONNECTORVERSION=\"([0-9]+\.[0-9]+\.[0-9]+)\"/\1/p" bitwarden.sh) + KEY_CONNECTOR_VERSION=$(grep '^ *"keyConnectorVersion":' version.json | awk '{ print $2 }' | sed -e 's/,$//' -e 's/^"//' -e 's/"$//') echo "Key Connector Version: $KEY_CONNECTOR_VERSION" echo "Latest Key Connector Version: $LATEST_KEY_CONNECTOR_VERSION" if [ "$KEY_CONNECTOR_VERSION" != "$LATEST_KEY_CONNECTOR_VERSION" ]; then @@ -111,23 +111,17 @@ jobs: - name: Update Core Version env: VERSION: ${{ needs.setup.outputs.core_version }} - run: | - sed -i -e "/^\s*COREVERSION\s*=\s*/s/[0-9]\+.[0-9]\+.[0-9]\+/$VERSION/" bitwarden.sh - sed -i -e "/^\s*\$coreVersion\s*=\s*/s/[0-9]\+.[0-9]\+.[0-9]\+/$VERSION/" bitwarden.ps1 + run: sed -i -e '/"coreVersion":/ s/"coreVersion":[^,]*/"coreVersion":"'$VERSION'"/' version.json - name: Update Web Version env: VERSION: ${{ needs.setup.outputs.web_version }} - run: | - sed -i -e "/^\s*WEBVERSION\s*=\s*/s/[0-9]\+.[0-9]\+.[0-9]\+/$VERSION/" bitwarden.sh - sed -i -e "/^\s*\$webVersion\s*=\s*/s/[0-9]\+.[0-9]\+.[0-9]\+/$VERSION/" bitwarden.ps1 + run: sed -i -e '/"webVersion":/ s/"webVersion":[^,]*/"webVersion":"'$VERSION'"/' version.json - name: Update Key Connector Version env: VERSION: ${{ needs.setup.outputs.key_connector_version }} - run: | - sed -i -e "/^\s*KEYCONNECTORVERSION\s*=\s*/s/[0-9]\+.[0-9]\+.[0-9]\+/$VERSION/" bitwarden.sh - sed -i -e "/^\s*\$keyConnectorVersion\s*=\s*/s/[0-9]\+.[0-9]\+.[0-9]\+/$VERSION/" bitwarden.ps1 + run: sed -i -e '/"keyConnectorVersion":/ s/"keyConnectorVersion":[^,]*/"keyConnectorVersion":"'$VERSION'"/' version.json - name: Commit updated files run: | @@ -158,4 +152,4 @@ jobs: - [X] Other ## Objective - Automated version updates to core, web, and key-connector versions in bitwarden.sh and bitwarden.ps1." + Automated version updates to core, web, and key-connector versions in `version.json`." diff --git a/bitwarden.ps1 b/bitwarden.ps1 index 7c631c9..5f3c285 100644 --- a/bitwarden.ps1 +++ b/bitwarden.ps1 @@ -26,11 +26,12 @@ if ($output -eq "") { $scriptsDir = "${output}\scripts" $bitwardenScriptUrl = "https://go.btwrdn.co/bw-ps" $runScriptUrl = "https://go.btwrdn.co/bw-ps-run" +$versionEndpoint = "https://go.btwrdn.co/bw-sh-versions" # Please do not create pull requests modifying the version numbers. -$coreVersion = "1.47.1" -$webVersion = "2.27.0" -$keyConnectorVersion = "1.0.1" +$coreVersion = (Invoke-RestMethod -Uri $versionEndpoint).versions.coreVersion +$webVersion = (Invoke-RestMethod -Uri $versionEndpoint).versions.webVersion +$keyConnectorVersion = (Invoke-RestMethod -Uri $versionEndpoint).versions.keyConnectorVersion # Functions diff --git a/bitwarden.sh b/bitwarden.sh index b2ac215..c9372f6 100755 --- a/bitwarden.sh +++ b/bitwarden.sh @@ -39,11 +39,16 @@ fi SCRIPTS_DIR="$OUTPUT/scripts" BITWARDEN_SCRIPT_URL="https://go.btwrdn.co/bw-sh" RUN_SCRIPT_URL="https://go.btwrdn.co/bw-sh-run" +VERSION_ENDPOINT="https://go.btwrdn.co/bw-sh-versions" # Please do not create pull requests modifying the version numbers. -COREVERSION="1.47.1" -WEBVERSION="2.27.0" -KEYCONNECTORVERSION="1.0.1" +function getVersion() { + echo $(curl -sL $VERSION_ENDPOINT | grep '^ *"'${1}'":' | awk '{ print $2 }' | sed -e 's/,$//' -e 's/^"//' -e 's/"$//') +} + +COREVERSION=$(getVersion coreVersion) +WEBVERSION=$(getVersion webVersion) +KEYCONNECTORVERSION=$(getVersion keyConnectorVersion) echo "bitwarden.sh version $COREVERSION" docker --version diff --git a/version.json b/version.json index 4087e7a..2d7874b 100644 --- a/version.json +++ b/version.json @@ -1,7 +1,7 @@ { "versions": { - "coreVersion": "1.47.0", - "webVersion": "2.26.0", - "keyConnectorVersion": "1.0.1" + "coreVersion":"1.47.1", + "webVersion":"2.27.0", + "keyConnectorVersion":"1.0.1" } -} +} \ No newline at end of file