diff --git a/.appveyor/appveyor.yml b/.appveyor/appveyor.yml deleted file mode 100644 index 6a9780d5..00000000 --- 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/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4bdfbfe0..fd642862 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 0e507b06..95392db6 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" }