Skip to content

Commit a7aadf0

Browse files
authored
Fix marketplace image versioning by passing release version from release pipeline (#485)
* Fix azure release version * fix all * use env vars
1 parent 7702d19 commit a7aadf0

4 files changed

Lines changed: 58 additions & 16 deletions

File tree

.github/workflows/release-aws.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
- "CommonMarketplace/**"
88

99
workflow_dispatch:
10+
inputs:
11+
release_version:
12+
description: "Release version (e.g., 2026.3.2)"
13+
required: false
14+
type: string
1015

1116
concurrency:
1217
group: ${{ github.workflow }}
@@ -47,8 +52,10 @@ jobs:
4752
- name: Log out from Azure
4853
uses: bitwarden/gh-actions/azure-logout@main
4954

50-
- name: Set version from version.json
55+
- name: Set version
5156
id: set-version
57+
env:
58+
RELEASE_VERSION: ${{ inputs.release_version }}
5259
run: |
5360
VERSION=$(jq -r '.versions.coreVersion' version.json)
5461
if [[ -z "$VERSION" ]]; then
@@ -57,6 +64,14 @@ jobs:
5764
fi
5865
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
5966
67+
# Use the release version input when dispatched from the release
68+
# pipeline. Fall back to coreVersion for other builds.
69+
if [[ -n "$RELEASE_VERSION" ]]; then
70+
echo "img_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
71+
else
72+
echo "img_version=$VERSION" >> "$GITHUB_OUTPUT"
73+
fi
74+
6075
- name: Set up Hashicorp Packer
6176
uses: hashicorp/setup-packer@1aa358be5cf73883762b302a3a03abd66e75b232 # v3.1.0
6277

@@ -65,7 +80,7 @@ jobs:
6580
AWS_ACCESS_KEY_ID: ${{ steps.retrieve-secrets.outputs.aws-marketplace-access-key-id }}
6681
AWS_SECRET_ACCESS_KEY: ${{ steps.retrieve-secrets.outputs.aws-marketplace-secret-access-key }}
6782
AWS_DEFAULT_REGION: "us-east-1"
68-
AWS_IMG_VERSION: ${{ steps.set-version.outputs.version }}
83+
AWS_IMG_VERSION: ${{ steps.set-version.outputs.img_version }}
6984
working-directory: ./AWSMarketplace
7085
run: |
7186
packer version
@@ -135,7 +150,7 @@ jobs:
135150
136151
- name: AWS Image Cleanup
137152
working-directory: ./AWSMarketplace
138-
if: ${{ github.event_name != 'release' && github.event_name != 'workflow_dispatch' }}
153+
if: ${{ inputs.release_version == '' }}
139154
env:
140155
AWS_ACCESS_KEY_ID: ${{ steps.retrieve-secrets.outputs.aws-marketplace-access-key-id }}
141156
AWS_SECRET_ACCESS_KEY: ${{ steps.retrieve-secrets.outputs.aws-marketplace-secret-access-key }}

.github/workflows/release-azure.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
- "CommonMarketplace/**"
88

99
workflow_dispatch:
10+
inputs:
11+
release_version:
12+
description: "Release version (e.g., 2026.3.2)"
13+
required: false
14+
type: string
1015

1116
concurrency:
1217
group: ${{ github.workflow }}
@@ -43,8 +48,11 @@ jobs:
4348
keyvault: "gh-self-host"
4449
secrets: "azure-marketplace-subscription-id"
4550

46-
- name: Set version from version.json
51+
- name: Set version
4752
id: set-version
53+
env:
54+
RELEASE_VERSION: ${{ inputs.release_version }}
55+
RUN_NUMBER: ${{ github.run_number }}
4856
run: |
4957
VERSION=$(jq -r '.versions.coreVersion' version.json)
5058
if [[ -z "$VERSION" ]]; then
@@ -53,12 +61,13 @@ jobs:
5361
fi
5462
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
5563
56-
# Use a dev version for non-release builds to avoid colliding with
57-
# published gallery image versions
58-
if [[ "${{ github.event_name }}" == "release" ]]; then
59-
echo "img_version=$VERSION" >> "$GITHUB_OUTPUT"
64+
# Use the release version input when dispatched from the release
65+
# pipeline. Fall back to a dev version for push builds to avoid
66+
# colliding with published gallery image versions.
67+
if [[ -n "$RELEASE_VERSION" ]]; then
68+
echo "img_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
6069
else
61-
echo "img_version=0.0.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
70+
echo "img_version=0.0.$RUN_NUMBER" >> "$GITHUB_OUTPUT"
6271
fi
6372
6473
- name: Set up Hashicorp Packer
@@ -134,7 +143,7 @@ jobs:
134143
135144
- name: Azure Image Cleanup
136145
working-directory: ./AzureMarketplace
137-
if: ${{ github.event_name != 'release' && github.event_name != 'workflow_dispatch' }}
146+
if: ${{ inputs.release_version == '' }}
138147
env:
139148
RESOURCE_GROUP: rg-marketplace
140149
GALLERY_NAME: bitwarden_marketplace

.github/workflows/release-digital-ocean.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
- "CommonMarketplace/**"
88

99
workflow_dispatch:
10+
inputs:
11+
release_version:
12+
description: "Release version (e.g., 2026.3.2)"
13+
required: false
14+
type: string
1015

1116
concurrency:
1217
group: ${{ github.workflow }}
@@ -46,8 +51,10 @@ jobs:
4651
- name: Log out from Azure
4752
uses: bitwarden/gh-actions/azure-logout@main
4853

49-
- name: Set version from version.json
54+
- name: Set version
5055
id: set-version
56+
env:
57+
RELEASE_VERSION: ${{ inputs.release_version }}
5158
run: |
5259
VERSION=$(jq -r '.versions.coreVersion' version.json)
5360
if [[ -z "$VERSION" ]]; then
@@ -56,13 +63,21 @@ jobs:
5663
fi
5764
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
5865
66+
# Use the release version input when dispatched from the release
67+
# pipeline. Fall back to coreVersion for other builds.
68+
if [[ -n "$RELEASE_VERSION" ]]; then
69+
echo "img_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
70+
else
71+
echo "img_version=$VERSION" >> "$GITHUB_OUTPUT"
72+
fi
73+
5974
- name: Set up Hashicorp Packer
6075
uses: hashicorp/setup-packer@1aa358be5cf73883762b302a3a03abd66e75b232 # v3.1.0
6176

6277
- name: Build Digital Ocean Image
6378
env:
6479
DIGITALOCEAN_TOKEN: ${{ steps.retrieve-secrets.outputs.digital-ocean-api-key }}
65-
DIGITALOCEAN_IMG_VERSION: ${{ steps.set-version.outputs.version }}
80+
DIGITALOCEAN_IMG_VERSION: ${{ steps.set-version.outputs.img_version }}
6681
working-directory: ./DigitalOceanMarketplace
6782
run: |
6883
packer version
@@ -138,7 +153,7 @@ jobs:
138153
139154
- name: Digital Ocean Image Cleanup
140155
working-directory: ./DigitalOceanMarketplace
141-
if: ${{ github.event_name != 'release' && github.event_name != 'workflow_dispatch' }}
156+
if: ${{ inputs.release_version == '' }}
142157
run: |
143158
# Get the ID from the snapshot build.
144159
DO_ARTIFACT=$(jq -r '.builds[-1].artifact_id' manifest.json | cut -d ":" -f2)

.github/workflows/release.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ jobs:
495495
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
496496
env:
497497
RELEASE_TAG: v${{ inputs.release_version }}
498+
RELEASE_VERSION: ${{ inputs.release_version }}
498499
with:
499500
github-token: ${{ steps.app-token.outputs.token }}
500501
script: |
@@ -503,13 +504,14 @@ jobs:
503504
repo: 'self-host',
504505
workflow_id: 'release-digital-ocean.yml',
505506
ref: process.env.RELEASE_TAG,
506-
inputs: {}
507+
inputs: { release_version: process.env.RELEASE_VERSION }
507508
});
508509
509510
- name: Trigger release-aws workflow
510511
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
511512
env:
512513
RELEASE_TAG: v${{ inputs.release_version }}
514+
RELEASE_VERSION: ${{ inputs.release_version }}
513515
with:
514516
github-token: ${{ steps.app-token.outputs.token }}
515517
script: |
@@ -518,13 +520,14 @@ jobs:
518520
repo: 'self-host',
519521
workflow_id: 'release-aws.yml',
520522
ref: process.env.RELEASE_TAG,
521-
inputs: {}
523+
inputs: { release_version: process.env.RELEASE_VERSION }
522524
});
523525
524526
- name: Trigger release-azure workflow
525527
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
526528
env:
527529
RELEASE_TAG: v${{ inputs.release_version }}
530+
RELEASE_VERSION: ${{ inputs.release_version }}
528531
with:
529532
github-token: ${{ steps.app-token.outputs.token }}
530533
script: |
@@ -533,5 +536,5 @@ jobs:
533536
repo: 'self-host',
534537
workflow_id: 'release-azure.yml',
535538
ref: process.env.RELEASE_TAG,
536-
inputs: {}
539+
inputs: { release_version: process.env.RELEASE_VERSION }
537540
});

0 commit comments

Comments
 (0)