Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): move chocolatey deployment to gha [#985] #1328

Merged
merged 2 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions .appveyor/appveyor.yml

This file was deleted.

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
Loading