Skip to content

Commit 3779520

Browse files
Refactor build-release workflow and update release action
Simplifies and cleans up the build-release GitHub Actions workflow by removing redundant comments, consolidating environment variables at the top level, and updating the gh-release action to v2. Also adds a conditional to the 'Make sqlpackage executable' step and streamlines Docker setup commands.
1 parent 2780de1 commit 3779520

File tree

1 file changed

+11
-29
lines changed

1 file changed

+11
-29
lines changed

.github/workflows/build-release.yml

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
name: Build and Publish Preview Release
22

3-
# This workflow builds the module and creates a preview release on GitHub
4-
# It triggers automatically when:
5-
# - The module version contains "preview" (checked on every push)
6-
# - Manually triggered via workflow_dispatch (useful when module is not found on PowerShell Gallery)
7-
#
8-
# To trigger a preview release:
9-
# 1. Set ModuleVersion in dbatools.library.psd1 to include "preview" (e.g., '2025.7.11-preview')
10-
# 2. OR manually trigger the workflow from GitHub Actions tab
11-
123
on:
134
push:
14-
# Runs on any branch, checks module version for "preview"
155
pull_request:
166
workflow_dispatch:
17-
# Manual trigger for when module is not available on PowerShell Gallery
187
inputs:
198
dbatools_branch:
209
description: 'dbatools branch to use (default: development)'
2110
required: false
2211
default: 'development'
2312

13+
env:
14+
TENANTID: ${{ secrets.TENANTID }}
15+
CLIENTID: ${{ secrets.CLIENTID }}
16+
CLIENTSECRET: ${{ secrets.CLIENTSECRET }}
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
CLIENT_GUID_SECRET: ${{ secrets.CLIENT_GUID_SECRET }}
19+
CLIENT_GUID: ${{ secrets.CLIENT_GUID }}
20+
SMODefaultModuleName: dbatools
21+
2422
jobs:
25-
# Setup job - downloads dependencies once for all other jobs
2623
setup-dependencies:
2724
runs-on: ubuntu-latest
2825
steps:
@@ -54,7 +51,6 @@ jobs:
5451
name: appveyor-repo
5552
path: appveyor-lab
5653

57-
# Windows build job - builds complete library with all components
5854
build-library:
5955
runs-on: windows-latest
6056
needs: setup-dependencies
@@ -78,6 +74,7 @@ jobs:
7874
run: .\build\build.ps1 -BuildZip
7975

8076
- name: Make sqlpackage executable
77+
if: runner.os != 'Windows'
8178
shell: pwsh
8279
run: |
8380
chmod +x ./artifacts/dbatools.library/core/lib/dac/linux/sqlpackage || true
@@ -129,7 +126,6 @@ jobs:
129126
name: dbatools-library-zip
130127
path: artifacts/dbatools.library.zip
131128

132-
# Test matrix - tests on all platforms with proper dependencies and environment
133129
test-matrix:
134130
name: Test on ${{ matrix.os }}
135131
runs-on: ${{ matrix.os }}
@@ -151,26 +147,14 @@ jobs:
151147
shell: pwsh
152148
working-directory: ${{ github.workspace }}
153149

154-
env:
155-
TENANTID: ${{ secrets.TENANTID }}
156-
CLIENTID: ${{ secrets.CLIENTID }}
157-
CLIENTSECRET: ${{ secrets.CLIENTSECRET }}
158-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159-
CLIENT_GUID_SECRET: ${{ secrets.CLIENT_GUID_SECRET }}
160-
CLIENT_GUID: ${{ secrets.CLIENT_GUID }}
161-
SMODefaultModuleName: dbatools
162-
163150
steps:
164151
- uses: actions/checkout@v4
165152

166153
- name: Setup docker images (Linux only)
167154
if: matrix.os == 'ubuntu-latest'
168155
run: |
169-
# create a shared network
170156
docker network create localnet
171-
# Expose engine and endpoint then setup a shared path for migrations
172157
docker run -p 1433:1433 --volume shared:/shared:z --name mssql1 --hostname mssql1 --network localnet -d dbatools/sqlinstance
173-
# Expose second engine and endpoint on different port
174158
docker run -p 14333:1433 --volume shared:/shared:z --name mssql2 --hostname mssql2 --network localnet -d dbatools/sqlinstance2
175159
176160
- name: Install local SQL engine via mssqlsuite (Windows only)
@@ -258,12 +242,10 @@ jobs:
258242
Write-Host "Running integration tests with ${{ matrix.script }} (Windows PowerShell)"
259243
$null = Invoke-Pester ${{ matrix.script }} -Output Detailed -PassThru
260244
261-
# Release job - creates GitHub release
262245
create-preview-release:
263246
needs: test-matrix
264247
runs-on: windows-latest
265248
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
266-
267249
steps:
268250
- name: Checkout code
269251
uses: actions/checkout@v4
@@ -312,7 +294,7 @@ jobs:
312294
"branch=$branch" >> $env:GITHUB_OUTPUT
313295
314296
- name: Create Preview Release
315-
uses: softprops/action-gh-release@v1
297+
uses: softprops/action-gh-release@v2
316298
with:
317299
tag_name: v${{ steps.get_version.outputs.version }}
318300
name: Preview Release v${{ steps.get_version.outputs.version }}

0 commit comments

Comments
 (0)