Skip to content

Create release for tagged versions. #13

Create release for tagged versions.

Create release for tagged versions. #13

name: Publish Package
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
branches:
- main
workflow_dispatch:
jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Carvel tools
shell: bash
run: curl -L https://carvel.dev/install.sh | bash
- name: Calculate variables
shell: bash
run: |
REPOSITORY_OWNER=${{github.repository_owner}}
echo "REPOSITORY_OWNER=${REPOSITORY_OWNER,,}" >>${GITHUB_ENV}
echo "REPOSITORY_TAG=${GITHUB_REF##*/}" >>${GITHUB_ENV}
echo "REPOSITORY_SHA_TAG=sha-${GITHUB_SHA::7}" >>${GITHUB_ENV}
- name: Create publish values file
shell: bash
run: |
cat <<EOF > publish-values.yaml
clusterIngress:
caCertificateRef:
namespace: default
name: ca-certificate
EOF
- name: Publish package bundle
shell: bash
run: |
# Create images lock file. We use a sample values file to pass validations
# We properly rewrite references to images via kbld
ytt --data-values-file publish-values.yaml -f bundle/config | \
kbld -f - --imgpkg-lock-output bundle/.imgpkg/images.yml
# Push the bundle to the registry
imgpkg push \
-b ghcr.io/${{env.REPOSITORY_OWNER}}/educates-lookup-service-installer:${{env.REPOSITORY_TAG}} \
--registry-username=${{github.actor}} \
--registry-password=${{secrets.GITHUB_TOKEN}} \
-f bundle
release-artifacts:
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- publish-package
steps:
- name: Calculate variables
shell: bash
run: |
REPOSITORY_TAG=${GITHUB_REF##*/}
if [[ "$REPOSITORY_TAG" == *-* ]]; then
PRERELEASE=true
else
PRERELEASE=false
fi
echo "REPOSITORY_TAG=${REPOSITORY_TAG}" >>${GITHUB_ENV}
echo "PRERELEASE=${PRERELEASE}" >>${GITHUB_ENV}
- name: Generate YAML release files.
shell: bash
run: |
cp resources/rbac.yaml educates-lookup-service-installer-app-rbac.yaml
cat resources/app.yaml | sed -e "s/:main/:${{env.REPOSITORY_TAG}}/" > educates-lookup-service-installer-app.yaml
- name: Generate file checksums for CLI binaries
shell: bash
run: |
sha256sum educates-lookup-service-installer-app.yaml >> checksums.txt
sha256sum educates-lookup-service-installer-app-rbac.yaml >> checksums.txt
echo 'File Checksums' >> release-notes.md
echo '--------------' >> release-notes.md
echo '```' >> release-notes.md
cat checksums.txt >> release-notes.md
echo '```' >> release-notes.md
- uses: actions/upload-artifact@v4
with:
name: educates-lookup-service-installer-app.yaml
path: educates-lookup-service-installer-app.yaml
- uses: actions/upload-artifact@v4
with:
name: educates-lookup-service-installer-app-rbac.yaml
path: educates-lookup-service-installer-app-rbac.yaml
- uses: actions/upload-artifact@v4
with:
name: checksums.txt
path: checksums.txt
- uses: actions/upload-artifact@v4
with:
name: release-notes.md
path: release-notes.md
- name: Create release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{env.REPOSITORY_TAG}}
name: "educates-lookup-service:${{env.REPOSITORY_TAG}}"
draft: false
prerelease: ${{env.PRERELEASE}}
body_path: release-notes.md
files: |
checksums.txt
educates-lookup-service-installer-app.yaml
educates-lookup-service-installer-app-rbac.yaml