Skip to content

Commit

Permalink
feat(release): use single release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Nov 28, 2024
1 parent dfcccaa commit e3d067b
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/msi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: |
$version = $env:GITHUB_REF.TrimStart("refs/tags/v")
./build.ps1 -Architecture ${{ matrix.arch }} -Version $version -Download -Sign
./build.ps1 -Architecture ${{ matrix.arch }} -Version $version -Download -Sign -Upload
- name: Upload artifacts 🆙
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
Expand Down
148 changes: 148 additions & 0 deletions .github/workflows/release2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Release

on:
push:
branches:
- next
paths:
- "src/**"
- "packages/**"
- ".github/workflows/**"

jobs:
changelog:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.changelog.outputs.version }}
body: ${{ steps.changelog.outputs.clean_changelog }}
tag: ${{ steps.changelog.outputs.tag }}
skipped: ${{ steps.changelog.outputs.skipped }}
steps:
- name: Checkout code 👋
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Create changelog ✍️
id: changelog
uses: TriPSs/conventional-changelog-action@3c4970b6573374889b897403d2f1278c395ea0df
with:
github-token: ${{ secrets.github_token }}
skip-version-file: "true"
output-file: "false"
skip-commit: "true"
skip-on-empty: "true"
skip-tag: "true"

artifacts:
needs: changelog
if: ${{ needs.changelog.outputs.skipped == 'false' }}
runs-on: windows-latest
defaults:
run:
shell: pwsh
working-directory: ${{ github.workspace }}/build
steps:
- name: Checkout code 👋
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Install Go 🗳
uses: ./.github/workflows/composite/bootstrap-go
- name: Pre Build 😸
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
run: |
./pre.ps1 -Version ${{ needs.changelog.outputs.version }}
- name: Run GoReleaser 🚀
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf
with:
distribution: goreleaser
version: v2.3.2
args: release --clean --skip publish
workdir: src
env:
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
- name: Post Build 🤐
run: |
./post.ps1
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
name: build-artifacts
path: |
src/dist/posh-*
src/dist/themes.*
src/dist/checksums.*
msi:
needs:
- changelog
- artifacts
runs-on: windows-latest
strategy:
matrix:
arch: [x64, arm64, x86]
defaults:
run:
shell: pwsh
working-directory: ${{ github.workspace }}/packages/msi
steps:
- name: Checkout code 👋
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: build-artifacts
path: dist
- name: Install Wix Toolset 🛠
run: dotnet tool install --global wix
- name: Build installer 📦
id: build
env:
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: |
$version = '${{ needs.changelog.outputs.version }}'.TrimStart("v")
./build.ps1 -Architecture ${{ matrix.arch }} -Version $version -Copy -Sign
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
name: msi-artifact-${{ matrix.arch }}
path: |
packages/msi/out/install-${{ matrix.arch }}.msi
packages/msi/out/install-${{ matrix.arch }}.msi.sha256
- name: Upload to CDN
shell: cmd
working-directory: ${{ github.workspace }}/packages/msi/out
env:
CDN_CONNECTIONSTRING: ${{ secrets.CDN_CONNECTIONSTRING }}
run: |
set fileName=install-${{ matrix.arch }}.msi
az storage blob upload --container-name ${{ needs.changelog.outputs.version }} --file %fileName% --name %fileName% --connection-string %CDN_CONNECTIONSTRING%
az storage blob upload --container-name latest --file %fileName% --name %fileName% --overwrite true --connection-string %CDN_CONNECTIONSTRING%
release:
runs-on: ubuntu-latest
needs:
- changelog
- msi
steps:
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
path: dist
- name: Display structure of downloaded files
run: ls -R
- name: Set latest on CDN
shell: cmd
env:
CDN_CONNECTIONSTRING: ${{ secrets.CDN_CONNECTIONSTRING }}
run: |
set versionFile=version.txt
echo ${{ needs.changelog.outputs.version }} > %versionFile%
az storage blob upload --container-name 'latest' --file %versionFile% --name %versionFile% --overwrite true --connection-string %CDN_CONNECTIONSTRING%
# - name: Release 🎓
# uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974
# with:
# tag_name: ${{ needs.changelog.outputs.tag }}
# body: ${{ needs.changelog.outputs.body }}
# fail_on_unmatched_files: true
# token: ${{ secrets.GH_PAT }}
# files: |
# dist/posh-*
# dist/themes.*
# dist/checksums.*
# dist/install.*
16 changes: 16 additions & 0 deletions build/post.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Description: Post build script to compress the themes and generate SHA256 hashes for all files in the dist folder

# Compress all themes
$compress = @{
Path = "../themes/*.omp.*"
CompressionLevel = "Fastest"
DestinationPath = "../src/dist/themes.zip"
}
Compress-Archive @compress

# Generate SHA256 hashes for all files in the dist folder
Get-ChildItem ./dist -Exclude *.yaml, *.sig | Get-Unique |
Foreach-Object {
$zipHash = Get-FileHash $_.FullName -Algorithm SHA256
$zipHash.Hash | Out-File -Encoding 'UTF8' "../src/dist/$($_.Name).sha256"
}
30 changes: 30 additions & 0 deletions build/pre.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Param
(
[string]
$Version,
[parameter(Mandatory = $false)]
[string]
$SDKVersion = "10.0.22621.0"
)

git config --global user.name "GitHub Actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag $Version --force

$PSDefaultParameterValues['Out-File:Encoding'] = 'UTF8'

$shaSigningKeyLocation = Join-Path -Path $env:RUNNER_TEMP -ChildPath sha_signing_key.pem
$env:SIGNING_KEY > $shaSigningKeyLocation
Write-Output "SHA_SIGNING_KEY_LOCATION=$shaSigningKeyLocation" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

# install code signing dlib
nuget.exe install Microsoft.Trusted.Signing.Client -Version 1.0.60 -ExcludeVersion -OutputDirectory $env:RUNNER_TEMP
Write-Output "SIGNTOOLDLIB=$env:RUNNER_TEMP/Microsoft.Trusted.Signing.Client/bin/x64/Azure.CodeSigning.Dlib.dll" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

# requires Windows Dev Kit 10.0.22621.0
$signtool = "C:/Program Files (x86)/Windows Kits/10/bin/$SDKVersion/x64/signtool.exe"
Write-Output "SIGNTOOL=$signtool" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

# openssl
$openssl = 'C:/Program Files/Git/usr/bin/openssl.exe'
Write-Output "OPENSSL=$openssl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
15 changes: 7 additions & 8 deletions packages/msi/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,32 @@ Param
[parameter(Mandatory = $false)]
[string]
$SDKVersion = "10.0.22621.0",
[switch]$Download,
[switch]$Sign
[switch]$Sign,
[switch]$Copy
)

$PSDefaultParameterValues['Out-File:Encoding'] = 'UTF8'

New-Item -Path "." -Name "dist" -ItemType Directory -ErrorAction SilentlyContinue
New-Item -Path "." -Name "out" -ItemType Directory -ErrorAction SilentlyContinue

if ($Download) {
# download the executable
if ($Copy) {
switch ($Architecture) {
'x86' { $file = "posh-windows-386.exe" }
'x64' { $file = "posh-windows-amd64.exe" }
Default { $file = "posh-windows-$Architecture.exe" }
}

$name = "oh-my-posh.exe"
$url = "https://github.com/jandedobbeleer/oh-my-posh/releases/download/v$Version/$file"
Invoke-WebRequest $url -Out "./dist/$($name)"
# copy the correct architecture to ./dist
Copy-Item -Path "../../dist/$file" -Destination "./dist/oh-my-posh.exe"
}

# variables
$env:VERSION = $Version

# create MSI
$installer = "./out/install-$Architecture.msi"
$fileName = "install-$Architecture.msi"
$installer = "./out/$fileName"
wix build -arch $Architecture -out $installer .\oh-my-posh.wxs

if ($Sign) {
Expand Down

0 comments on commit e3d067b

Please sign in to comment.