Skip to content

refactor: simplify and modularize procDir function (#236) #24

refactor: simplify and modularize procDir function (#236)

refactor: simplify and modularize procDir function (#236) #24

Workflow file for this run

name: Release
on:
push:
branches:
- main
workflow_dispatch:
jobs:
tag:
name: Tag build
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gitversion.outputs.FullSemVer }}
prerelease: ${{ steps.gitversion.outputs.PreReleaseTagWithDash }}
nuget: ${{ steps.gitversion.outputs.NuGetVersionV2 }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Version with GitVersion # https://github.com/marketplace/actions/use-actions
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
if: ${{ steps.gitversion.outputs.PreReleaseTagWithDash == '' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.gitversion.outputs.FullSemVer }}
release_branches: main
tag_prefix: v
release:
name: Create Release
runs-on: ubuntu-latest
needs: tag
if: ${{ needs.tag.outputs.prerelease == '' }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if commit is tagged
run: git describe --tags --exact-match
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ^1.17
id: go
- name: Run GoReleaser
uses: goreleaser/[email protected]
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Replace version in NuSpec file
uses: cschleiden/replace-tokens@v1
env:
GitVersion_NuGetVersionV2: ${{ needs.tag.outputs.nuget }}
with:
files: '["rmstale.nuspec"]'
- name: Create directory for chocolaty package
run: mkdir -p ${{ github.workspace }}/bin/chocolatey
- name: Package chocolaty binary # Output path refers to the mapped docker volume (/wksp)
uses: crazy-max/ghaction-chocolatey@v3
with:
args: pack rmstale.nuspec --outputdirectory /wksp/bin/chocolatey
- name: Push package to chocolatey.org
uses: crazy-max/ghaction-chocolatey@v3
with:
args: push /wksp/bin/chocolatey/rmstale.${{ needs.tag.outputs.version }}.nupkg --source https://push.chocolatey.org/ --apikey ${{ secrets.CHOCO_KEY }}
winget:
name: Publish winget package
runs-on: windows-latest
needs: release
environment: winget
steps:
- name: Submit danstis.rmstale package to WinGet Community Repository
run: |
$ErrorActionPreference = "Stop"
$wingetPackage = "danstis.rmstale"
$gitToken = "${{ secrets.WINGET_PAT }}"
$github = Invoke-RestMethod -uri "https://api.github.com/repos/danstis/rmstale/releases"
$targetRelease = $github | Where-Object {-not $_.draft -and -not $_.prerelease} | Select -First 1
$installerAmd64Url = $targetRelease | Select -ExpandProperty assets -First 1 | Where-Object {$_.name -match 'rmstale_.*_windows_amd64.zip'} | Select -ExpandProperty browser_download_url
$installerArm64Url = $targetRelease | Select -ExpandProperty assets -First 1 | Where-Object {$_.name -match 'rmstale_.*_windows_arm64.zip'} | Select -ExpandProperty browser_download_url
$installerX86Url = $targetRelease | Select -ExpandProperty assets -First 1 | Where-Object {$_.name -match 'rmstale_.*_windows_386.zip'} | Select -ExpandProperty browser_download_url
$ver = $targetRelease.tag_name.Trim("v")
if (-not $installerAmd64Url -or -not $installerArm64Url -or -not $installerX86Url -or -not $ver) {
Write-Error "One or more installer URLs are empty."
}
# getting latest wingetcreate file
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
try {
.\wingetcreate.exe update $wingetPackage --submit --version $ver --urls $installerAmd64Url $installerArm64Url $installerX86Url --token $gitToken
} catch {
Write-Error "Failed to submit the winget package: $_"
}