Skip to content

Commit

Permalink
Update publish-krewplugin.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
PixelRobots authored Oct 1, 2024
1 parent 2099427 commit a913dab
Showing 1 changed file with 26 additions and 42 deletions.
68 changes: 26 additions & 42 deletions .github/workflows/publish-krewplugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Publish Plugin to Krew
on:
push:
branches:
- '*' # Trigger on all branches
- '*'
release:
types:
- published
workflow_dispatch: # Allows manual triggering of the workflow
workflow_dispatch:

jobs:
windows:
publish:
runs-on: windows-latest

steps:
Expand All @@ -20,13 +20,15 @@ jobs:
with:
ref: ${{ github.ref }} # Check out the branch that triggered the workflow

# Ensure we're not on the main branch
- name: Check branch
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
echo "This workflow does not run on the main branch."
exit 1
fi
# # Get the version from KubeTidy.psd1
# - name: Get Version from Manifest
# id: get_version
# run: |
# # Get the version from the module manifest
# $manifest = Get-Content ./KubeTidy.psd1 -Raw | Out-String | Invoke-Expression
# $version = $manifest.ModuleVersion
# Write-Host "Version: $version"
# echo "::set-output name=version::$version" # Set the version as an output variable

# Update the KubeTidy.psm1 file for Krew Plugin
- name: Update KubeTidy.psm1 for Krew Plugin
Expand Down Expand Up @@ -78,47 +80,29 @@ jobs:
run: |
(Get-Content "kubectl-KubeTidy" -Raw) -replace "`r`n", "`n" | Set-Content "kubectl-KubeTidy"
linux:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.ref }} # Check out the branch that triggered the workflow

# Ensure we're not on the main branch
- name: Check branch
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
echo "This workflow does not run on the main branch."
exit 1
fi
# Create tar.gz files for Linux and Darwin
- name: Create Tar Files
run: |
# Get the version from the previous step
$version = "${{ github.ref_name }}"
$version = "${{ github.ref_name }}"
# Create output directory for the tar files
$outputDir = "krewplugin"
mkdir -p $outputDir
New-Item -ItemType Directory -Path $outputDir -Force
# Create platform-specific directories
$linuxDir = "$outputDir/linux"
$darwinDir = "$outputDir/darwin"
mkdir -p $linuxDir
mkdir -p $darwinDir
New-Item -ItemType Directory -Path $linuxDir -Force
New-Item -ItemType Directory -Path $darwinDir -Force
# Move the updated script to the appropriate platform directories
cp kubectl-KubeTidy "$linuxDir/kubectl-KubeTidy"
cp kubectl-KubeTidy "$darwinDir/kubectl-KubeTidy"
Copy-Item -Path "kubectl-KubeTidy" -Destination "$linuxDir/kubectl-KubeTidy"
Copy-Item -Path "kubectl-KubeTidy" -Destination "$darwinDir/kubectl-KubeTidy"
# Copy the Private folder into each platform directory
cp -r Private "$linuxDir/Private"
cp -r Private "$darwinDir/Private"
Copy-Item -Path "Private" -Destination "$linuxDir/Private" -Recurse -Force
Copy-Item -Path "Private" -Destination "$darwinDir/Private" -Recurse -Force
# Create tar.gz files for Linux and Darwin using the tar command
tar -czf "$outputDir/KubeTidy-linux-amd64-$version.tar.gz" -C "$linuxDir" .
Expand All @@ -129,8 +113,8 @@ jobs:
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref_name }} # Use the version from the output
release_name: KubeTidy Release ${{ github.ref_name }}
tag_name: ${{ github.ref_name }} # Use the version from the output
release_name: KubeTidy Release ${{ github.ref_name }}
draft: false
prerelease: false
env:
Expand All @@ -141,8 +125,8 @@ jobs:
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/krewplugin/KubeTidy-linux-amd64-${{ github.ref_name }}.tar.gz
asset_name: KubeTidy-linux-amd64-${{ github.ref_name }}.tar.gz
asset_path: ${{ github.workspace }}/krewplugin/KubeTidy-linux-amd64-${{ github.ref_name }}.tar.gz
asset_name: KubeTidy-linux-amd64-${{ github.ref_name }}.tar.gz
asset_content_type: application/gzip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -152,8 +136,8 @@ jobs:
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/krewplugin/KubeTidy-darwin-amd64-${{ github.ref_name }}.tar.gz
asset_name: KubeTidy-darwin-amd64-${{ github.ref_name }}.tar.gz
asset_path: ${{ github.workspace }}/krewplugin/KubeTidy-darwin-amd64-${{ github.ref_name }}.tar.gz
asset_name: KubeTidy-darwin-amd64-${{ github.ref_name }}.tar.gz
asset_content_type: application/gzip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit a913dab

Please sign in to comment.