Skip to content

Commit

Permalink
chore(ci): move chocolatey deployment to gha [Versent#985]
Browse files Browse the repository at this point in the history
  • Loading branch information
tinaboyce committed Aug 1, 2024
1 parent 7852300 commit 7795b57
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,61 @@ jobs:
with:
tag_name: ${{ env.VER_TAG }}
files: ${{ env.INSTALLER }}/out/*.msi

chocolatey:
name: Deploy to chocolatey
runs-on: windows-latest
permissions:
contents: write
needs: [release]
if: >- # https://github.com/actions/runner/issues/491
always() &&
(needs.release.result == 'success' || needs.release.result == 'skipped')
steps:
- name: Normalize tag values
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]] ; then
VER=${{ github.event.inputs.tag }}
else
VER=${GITHUB_REF/refs\/tags\//}
fi
VERSION=${VER//v}
echo "VER_TAG=$VER" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v3
with:
path: "C:\\Users\\runneradmin\\Documents\\PowerShell\\Modules"
key: ${{ runner.os }}-InvokeBuild

- name: Install required PowerShell modules
if: steps.cacher.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module InvokeBuild -ErrorAction Stop
- name: Invoke build script
env:
appName: saml2aws
shell: pwsh
run: Invoke-Build

- name: Deploy
shell: pwsh
env:
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
VERSION: ${{ env.VERSION }}
run: |
choco apikey --key "$env:CHOCOLATEY_API_KEY" --source "https://push.chocolatey.org/"
choco push ./choco/saml2aws.${env:VERSION}.nupkg --source "https://push.chocolatey.org/"
4 changes: 2 additions & 2 deletions default.build.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version 'Latest'

#$nameOfApp = 'saml2aws'
$version = ${env:APPVEYOR_REPO_TAG_NAME}.Split('v')[1]
$version = ${env:VER_TAG}.Split('v')[1]

task 'Compile Go libraries...' {
$ErrorActionPreference = 'Continue'
Expand All @@ -23,7 +23,7 @@ task 'Pack Choco...' {
}

task 'Zip for GH release...' {
7z a "${env:appName}.zip" "$env:APPVEYOR_BUILD_FOLDER\bin\${env:appName}.exe"
7z a "${env:appName}.zip" ".\bin\${env:appName}.exe"
$hash = Get-FileHash "${env:appName}.zip"
"$($hash.Hash) $(Split-Path $hash.Path -Leaf)" > "${env:appName}.zip.sha256"
}
Expand Down

0 comments on commit 7795b57

Please sign in to comment.