version update #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Release | |
on: | |
push: | |
tags: | |
- 'v*.*.*' # Triggers on version tags like v1.0.0 | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
pip install PyYAML | |
- name: Create release tarball | |
run: | | |
mkdir -p release | |
tar -czvf release/registry-plugin.tar.gz manifests/ plugin.yaml kubectl-registry.sh | |
- name: Generate SHA256 checksum | |
id: generate_sha256 | |
run: | | |
sha256sum release/registry-plugin.tar.gz | awk '{ print $1 }' > release/sha256.txt | |
- name: Update plugin.yaml with checksum and tag | |
run: | | |
SHA256=$(cat release/sha256.txt) | |
TAG=${GITHUB_REF/refs\/tags\//} | |
sed -i "s|uri: .*|uri: \"https://github.com/${{ github.repository }}/releases/download/${TAG}/my-krew-plugin.tar.gz\"|" plugin.yaml | |
sed -i "s|sha256: .*|sha256: \"${SHA256}\"|" plugin.yaml | |
sed -i "s|version: .*|version: \"${TAG}\"|" plugin.yaml | |
cp plugin.yaml release/plugin.yaml | |
- name: Commit updated plugin.yaml | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add plugin.yaml | |
git commit -m "Update plugin.yaml for release ${TAG}" | |
git push | |
- name: Upload release asset | |
uses: actions/upload-artifact@v3 | |
with: | |
name: registry-plugin | |
path: release/registry-plugin.tar.gz | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
body: | | |
This is an automatic release of registry-plugin. | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: release/registry-plugin.tar.gz | |
asset_name: registry-plugin.tar.gz | |
asset_content_type: application/gzip |