From 7795b57b444733c832581f9ccab6c1781bf50b3f Mon Sep 17 00:00:00 2001 From: Tina Boyce <12929562+tinaboyce@users.noreply.github.com> Date: Thu, 1 Aug 2024 23:22:40 +1000 Subject: [PATCH 1/2] chore(ci): move chocolatey deployment to gha [#985] --- .github/workflows/release.yml | 58 +++++++++++++++++++++++++++++++++++ default.build.ps1 | 4 +-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4bdfbfe0c..fd6428620 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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/" diff --git a/default.build.ps1 b/default.build.ps1 index 0e507b06e..95392db64 100644 --- a/default.build.ps1 +++ b/default.build.ps1 @@ -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' @@ -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" } From b9283b00044b70a90d6f5dcbc97436bd899587d4 Mon Sep 17 00:00:00 2001 From: Tina Boyce <12929562+tinaboyce@users.noreply.github.com> Date: Thu, 1 Aug 2024 23:34:39 +1000 Subject: [PATCH 2/2] chore(ci): remove appveyor config --- .appveyor/appveyor.yml | 57 ------------------------------------------ 1 file changed, 57 deletions(-) delete mode 100644 .appveyor/appveyor.yml diff --git a/.appveyor/appveyor.yml b/.appveyor/appveyor.yml deleted file mode 100644 index 6a9780d5d..000000000 --- a/.appveyor/appveyor.yml +++ /dev/null @@ -1,57 +0,0 @@ -skip_non_tags: true -image: Visual Studio 2019 -clone_folder: c:\gopath\src\github.com\versent\saml2aws -environment: - GOPATH: c:\gopath - CHOCOLATEY_APIKEY: - secure: 3kWTz99Qj+ipyaR73CxcJeGRRbmk84MF2ERDu6MyY10cjHAi6s3AVZ2Ccoa+Ioyt - appName: saml2aws -install: -- set PATH=C:\msys64\mingw64\bin;C:\go121\bin;%PATH% -- set GOROOT=C:\go121 -- ps: >- - $VerbosePreference = 'Continue' - - write-output $env:GOPATH - - write-output $env:APPVEYOR_REPO_TAG_NAME - - write-output $env:APPVEYOR_REPO_TAG_NAME.Split('v')[1] - - write-output $env:GOROOT - - $env:Path += ";`"$env:GOPATH\bin`";c:\go\bin;" - - write-output $env:PATH - - go version - - go env - - Install-PackageProvider -Name NuGet -Force - - Install-Module InvokeBuild -Force -build_script: -- cmd: go mod download -- ps: >- - Invoke-Build -test_script: -- cmd: go test -v . - -artifacts: -- path: $(appName).zip -- path: $(appName).zip.sha256 -- path: 'choco/$(appName).*.nupkg' -- path: 'choco/$(appName).*.nupkg.sha256' -#deploy: -#- provider: GitHub -# release: saml2aws-$(appveyor_build_version) -# auth_token: -# secure: kxO8LOQfcXH15OdilgteFKRn4Y7vUQND84WaR2fgghgiwTTHPLgKV1j+6o/8Ggjx -# artifact: saml2aws.zip, saml2aws.zip.sha256, choco/saml2aws.1.3.2.nupkg, choco/saml2aws.1.3.2.nupkg.sha256 -# draft: true -deploy_script: -- ps: >- - choco apiKey -k $env:CHOCOLATEY_APIKEY -s https://push.chocolatey.org/ - - choco push ./choco/${env:appName}.$(($env:APPVEYOR_REPO_TAG_NAME).Split('v')[1]).nupkg -s https://push.chocolatey.org/