Skip to content

feat(drive): add star/unstar operations and --ids flag (#104) #20

feat(drive): add star/unstar operations and --ids flag (#104)

feat(drive): add star/unstar operations and --ids flag (#104) #20

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to build (e.g., v1.0.0)'
required: true
type: string
permissions:
contents: write
jobs:
goreleaser:
runs-on: ubuntu-latest
env:
TAG: ${{ github.ref_name || inputs.tag }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.TAG }}
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
chocolatey:
needs: goreleaser
runs-on: windows-latest
continue-on-error: true
env:
TAG: ${{ github.ref_name || inputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Get checksums from release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download "${{ env.TAG }}" --repo ${{ github.repository }} --pattern "checksums.txt" --dir .
$checksums = Get-Content checksums.txt
$x64Hash = ($checksums | Select-String "windows_amd64.zip").Line.Split()[0]
$arm64Hash = ($checksums | Select-String "windows_arm64.zip").Line.Split()[0]
Write-Host "x64 SHA256: $x64Hash"
Write-Host "arm64 SHA256: $arm64Hash"
echo "X64_HASH=$x64Hash" >> $env:GITHUB_ENV
echo "ARM64_HASH=$arm64Hash" >> $env:GITHUB_ENV
- name: Update version and checksums
shell: pwsh
run: |
$version = "${{ env.TAG }}".TrimStart('v')
# Update version in nuspec
$nuspec = 'packaging/chocolatey/google-readonly.nuspec'
(Get-Content $nuspec) -replace '<version>0.0.0</version>', "<version>$version</version>" | Set-Content $nuspec
Write-Host "Updated nuspec to version $version"
# Inject checksums into install script
$script = 'packaging/chocolatey/tools/chocolateyInstall.ps1'
$content = Get-Content $script -Raw
$content = $content -replace 'CHECKSUM_AMD64_PLACEHOLDER', $env:X64_HASH
$content = $content -replace 'CHECKSUM_ARM64_PLACEHOLDER', $env:ARM64_HASH
Set-Content $script $content
Write-Host "Injected checksums into install script"
- name: Pack Chocolatey package
shell: pwsh
run: |
cd packaging/chocolatey
choco pack
Get-ChildItem *.nupkg
- name: Push to Chocolatey
shell: pwsh
run: |
cd packaging/chocolatey
choco push (Get-ChildItem *.nupkg).Name --source https://push.chocolatey.org/ --key ${{ secrets.CHOCOLATEY_API_KEY }}
winget:
needs: goreleaser
runs-on: windows-latest
continue-on-error: true
env:
TAG: ${{ github.ref_name || inputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Install wingetcreate
shell: pwsh
run: |
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
- name: Check if manifest exists in winget-pkgs
id: check-manifest
shell: pwsh
run: |
$response = Invoke-WebRequest -Uri "https://api.github.com/repos/microsoft/winget-pkgs/contents/manifests/o/OpenCLICollective/google-readonly" -Method Head -SkipHttpErrorCheck
if ($response.StatusCode -eq 200) {
Write-Host "Manifest exists - will use wingetcreate update"
echo "exists=true" >> $env:GITHUB_OUTPUT
} else {
Write-Host "Manifest does not exist - will use wingetcreate submit"
echo "exists=false" >> $env:GITHUB_OUTPUT
}
- name: Get checksums from release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download "${{ env.TAG }}" --repo ${{ github.repository }} --pattern "checksums.txt" --dir .
$checksums = Get-Content checksums.txt
$x64Hash = ($checksums | Select-String "windows_amd64.zip").Line.Split()[0]
$arm64Hash = ($checksums | Select-String "windows_arm64.zip").Line.Split()[0]
Write-Host "x64 SHA256: $x64Hash"
Write-Host "arm64 SHA256: $arm64Hash"
echo "X64_HASH=$x64Hash" >> $env:GITHUB_ENV
echo "ARM64_HASH=$arm64Hash" >> $env:GITHUB_ENV
- name: Update manifest (existing package)
if: steps.check-manifest.outputs.exists == 'true'
shell: pwsh
env:
WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }}
run: |
$version = "${{ env.TAG }}".TrimStart('v')
$x64 = "https://github.com/open-cli-collective/google-readonly/releases/download/${{ env.TAG }}/gro_v${version}_windows_amd64.zip"
$arm64 = "https://github.com/open-cli-collective/google-readonly/releases/download/${{ env.TAG }}/gro_v${version}_windows_arm64.zip"
Write-Host "Updating existing manifest to version $version"
Write-Host "x64 URL: $x64"
Write-Host "arm64 URL: $arm64"
./wingetcreate.exe update OpenCLICollective.google-readonly --version $version --urls $x64 $arm64 --submit --token $env:WINGET_GITHUB_TOKEN
- name: Create manifest (new package)
if: steps.check-manifest.outputs.exists == 'false'
shell: pwsh
env:
WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }}
run: |
$version = "${{ env.TAG }}".TrimStart('v')
$manifestDir = "manifests"
New-Item -ItemType Directory -Path $manifestDir -Force | Out-Null
# Update version manifest
$versionManifest = Get-Content "packaging/winget/OpenCLICollective.google-readonly.yaml" -Raw
$versionManifest = $versionManifest -replace "0\.0\.0", $version
Set-Content "$manifestDir/OpenCLICollective.google-readonly.yaml" $versionManifest
# Update locale manifest
$localeManifest = Get-Content "packaging/winget/OpenCLICollective.google-readonly.locale.en-US.yaml" -Raw
$localeManifest = $localeManifest -replace "0\.0\.0", $version
Set-Content "$manifestDir/OpenCLICollective.google-readonly.locale.en-US.yaml" $localeManifest
# Update installer manifest with version and real checksums
$installerManifest = Get-Content "packaging/winget/OpenCLICollective.google-readonly.installer.yaml" -Raw
$installerManifest = $installerManifest -replace "0\.0\.0", $version
# Use .NET regex for sequential replacement (PowerShell -replace doesn't support count)
$regex = [regex]"0{64}"
$installerManifest = $regex.Replace($installerManifest, $env:X64_HASH, 1)
$installerManifest = $regex.Replace($installerManifest, $env:ARM64_HASH, 1)
Set-Content "$manifestDir/OpenCLICollective.google-readonly.installer.yaml" $installerManifest
Write-Host "Generated manifests:"
Get-ChildItem $manifestDir | ForEach-Object { Write-Host " $_" }
Write-Host "`nValidating manifests..."
winget validate --manifest $manifestDir
if ($LASTEXITCODE -ne 0) {
Write-Error "Manifest validation failed"
exit 1
}
Write-Host "Validation passed!"
Write-Host "`nSubmitting new package to Winget..."
./wingetcreate.exe submit --token $env:WINGET_GITHUB_TOKEN $manifestDir
snap:
if: false # Temporarily disabled - waiting for personal-files interface approval
needs: goreleaser
runs-on: ubuntu-latest
env:
TAG: ${{ github.ref_name || inputs.tag }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.TAG }}
fetch-depth: 0
- name: Set snap version from tag
run: |
VERSION="${TAG#v}"
sed -i "s/^version: git$/version: '${VERSION}'/" snap/snapcraft.yaml
echo "Snap version: ${VERSION}"
grep '^version:' snap/snapcraft.yaml
- name: Build snap
uses: snapcore/action-build@v1
id: build
- name: Publish to Snapcraft Store
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
with:
snap: ${{ steps.build.outputs.snap }}
release: stable
linux-packages:
needs: goreleaser
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Trigger linux-packages repo update
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.LINUX_PACKAGES_DISPATCH_TOKEN }}
repository: open-cli-collective/linux-packages
event-type: package-release
client-payload: |-
{
"package": "google-readonly",
"version": "${{ github.ref_name }}",
"repo": "open-cli-collective/google-readonly"
}