Skip to content

publish assets after release #11

publish assets after release

publish assets after release #11

Workflow file for this run

---
# yamllint disable rule:line-length
name: publish assets after release
on: # yamllint disable-line rule:truthy
release:
types: [published] # triggers on release and pre-release
workflow_dispatch: # Useful for testing, but not necessary
permissions:
contents: write
env:
GO_VERSION: "1.25"
KUBECTL_VERSION: "1.32.2"
KUBECONFIG: /tmp/kubeconfig
jobs:
# Future - could also publish helm charts for any release (pre-release or release)
#publish-helm-charts:
attach-kubectl-volsync:
name: Build kubectl-volsync asset attach to release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
GOOS: [linux, darwin]
env:
GOOS: ${{ matrix.GOOS }}
steps:
- name: Checkout source
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{github.event.release.tag_name}}
# Fetch whole history so we can properly determine the version string
# (required by krew validation)
fetch-depth: 0
- name: Determine architecture
id: arch
run: |
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
echo "ARCH=$ARCH" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: ${{ env.GO_VERSION }}
- name: Install kubectl
run: |
curl -fsSLO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/${{ env.GOOS }}/${{ env.ARCH }}/kubectl"
sudo install ./kubectl /usr/local/bin/
kubectl version --client
kubectl version --client | grep -q ${KUBECTL_VERSION}
if: ${{ env.GOOS == 'linux' }}
- name: Install krew
# https://krew.sigs.k8s.io/docs/user-guide/setup/install/
run: |
cd "$(mktemp -d)"
OS="$(uname | tr '[:upper:]' '[:lower:]')"
KREW="krew-${OS}_${{ env.ARCH }}"
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz"
tar zxvf "${KREW}.tar.gz"
./"${KREW}" install krew
echo "${KREW_ROOT:-$HOME/.krew}/bin" >> $GITHUB_PATH
if: ${{ env.GOOS == 'linux' }}
# Build & test linux versions of kubectl-volsync
- name: Test build/install of plugin via krew
run: make test-krew # Will build the plugin and output to bin/kubectl-volsync.tar.gz
if: ${{ env.GOOS == 'linux' }}
# Build (no test) darwin versions of kubectl-volsync pkged as .tar.gz
- name: Build darwin kubectl-volsync binary
run: make krew-plugin-manifest
if: ${{ env.GOOS == 'darwin' }}
- name: Attach kubectl-volsync asset to release
env:
GH_TOKEN: ${{ github.token }}
run: |
cp bin/kubectl-volsync.tar.gz bin/kubectl-volsync-${{ env.GOOS }}-${{ env.ARCH }}.tar.gz
gh release upload ${{github.event.release.tag_name}} bin/kubectl-volsync-${{ env.GOOS }}-${{ env.ARCH }}.tar.gz
publish-kubectl-volsync:
name: open PR in krew-index for kubectl-volsync
needs: [attach-kubectl-volsync]
runs-on: ubuntu-24.04
if: "!github.event.release.prerelease"
steps:
- name: Checkout source
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{github.event.release.tag_name}}
- name: Install Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: ${{ env.GO_VERSION }}
- name: Update new version in krew-index
uses: rajatjindal/krew-release-bot@c970b8a8f6dbc2f2285a26e3ae160903b87002c3 # v0.0.51