Skip to content

Commit

Permalink
remove pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
ranchodeluxe committed Jul 16, 2024
1 parent 0f652e4 commit e4f7421
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 187 deletions.
334 changes: 167 additions & 167 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -1,169 +1,169 @@
name: pre-release helm chart

on:
pull_request:
branches: [ "main" ]
#types: [ closed ]
types: [ opened, reopened, synchronize ]

env:
HELM_VERSION: v3.15.2

jobs:
pre-release:
#if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # ensure the full history is fetched so we can compare changes

- uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}

- name: install github cli
run: |
sudo apt-get update
sudo apt-get install -y gh
- name: install yq
uses: mikefarah/yq@master

# - name: setup upterm session
# uses: lhotari/action-upterm@v1

- name: check if 'release-apply' label exists
id: check_label
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
LABELS=$(gh pr view $PR_NUMBER --json labels --jq '.labels[].name')
echo "Labels: $LABELS"
if echo "$LABELS" | grep -q "release-apply"; then
echo "Label 'release-apply' found."
# PRs with label "release-label" are created at the end of this workflow and we don't want infinite loops
echo "The pull request is merged and has the 'release-apply' label. Nothing to do. Exiting with success"
echo "continue=false" >>$GITHUB_OUTPUT
exit 0
else
echo "Label 'release-apply' not found."
echo "continue=true" >>$GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: check for changes in helm-chart directory
id: check_changes
run: |
git fetch --all
# check for changes between HEAD and previous commit in a specific directory
if ! git diff --quiet HEAD~ -- ./helm-chart/eoapi/; then
echo "Changes detected in the ./helm-chart/eoapi/ directory."
echo "continue=true" >> $GITHUB_OUTPUT
else
echo "No changes detected in the ./helm-chart/eoapi directory. Exiting."
echo "continue=false" >> $GITHUB_OUTPUT
exit 0
fi
- name: determine version increment
if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true'
id: determine-version
run: |
PR_TITLE=$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]')
if [[ "$PR_TITLE" =~ "major:" ]]; then
echo "version_type=major" >> $GITHUB_ENV
elif [[ "$PR_TITLE" =~ "minor:" ]]; then
echo "version_type=minor" >> $GITHUB_ENV
else
echo "version_type=patch" >> $GITHUB_ENV
fi
echo "Version increment type: ${{ env.version_type }}"
- name: bump chart versions
if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true'
id: bump-version
run: |
cd helm-chart/eoapi
VERSION_TYPE=${{ env.version_type }}
CURRENT_VERSION=$(grep '^version:' Chart.yaml | awk '{print $2}')
# strip double quotes
CURRENT_VERSION=${CURRENT_VERSION#\"}
CURRENT_VERSION=${CURRENT_VERSION%\"}
CURRENT_APP_VERSION=$(grep '^appVersion:' Chart.yaml | awk '{print $2}')
# strip double quotes
CURRENT_APP_VERSION=${CURRENT_APP_VERSION#\"}
CURRENT_APP_VERSION=${CURRENT_APP_VERSION%\"}
IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION"
IFS='.' read -r -a APP_VERSION_PARTS <<< "$CURRENT_APP_VERSION"
if [[ "$VERSION_TYPE" == "major" ]]; then
NEW_VERSION="$((VERSION_PARTS[0] + 1)).0.0"
# appVersion does not need to follow semvar
NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))"
elif [[ "$VERSION_TYPE" == "minor" ]]; then
NEW_VERSION="${VERSION_PARTS[0]}.$((VERSION_PARTS[1] + 1)).0"
# appVersion does not need to follow semvar
NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))"
else
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$((VERSION_PARTS[2] + 1))"
# appVersion does not need to follow semvar
NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))"
fi
# export so strenv picks them up
export NEW_VERSION
export NEW_APP_VERSION
yq -i '.version = strenv(NEW_VERSION)' Chart.yaml
yq -i '.appVersion = strenv(NEW_APP_VERSION)' Chart.yaml
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
echo "New version: $NEW_VERSION"
echo "New app version: $NEW_APP_VERSION"
- uses: actions/github-script@v6
if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true'
with:
script: |
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['release-apply']
})
- name: commit chart version bump
if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true'
run: |
TAG="v${{ env.new_version }}"
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git fetch origin
git checkout ${{ github.head_ref }}
git add -A
git commit -m "release version to v${{ env.new_version }}"
# only tag main branch in manual release
# git tag "v${{ env.new_version }}"
git push origin ${{ github.head_ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: create pr
#name: pre-release helm chart
#
#on:
# pull_request:
# branches: [ "main" ]
# #types: [ closed ]
# types: [ opened, reopened, synchronize ]
#
#env:
# HELM_VERSION: v3.15.2
#
#jobs:
# pre-release:
# #if: github.event.pull_request.merged == true
# runs-on: ubuntu-latest
#
# steps:
# - name: checkout code
# uses: actions/checkout@v4
# with:
# fetch-depth: 0 # ensure the full history is fetched so we can compare changes
#
# - uses: azure/setup-helm@v4
# with:
# version: ${{ env.HELM_VERSION }}
#
# - name: install github cli
# run: |
# sudo apt-get update
# sudo apt-get install -y gh
#
# - name: install yq
# uses: mikefarah/yq@master
#
## - name: setup upterm session
## uses: lhotari/action-upterm@v1
#
# - name: check if 'release-apply' label exists
# id: check_label
# run: |
# PR_NUMBER=${{ github.event.pull_request.number }}
# LABELS=$(gh pr view $PR_NUMBER --json labels --jq '.labels[].name')
# echo "Labels: $LABELS"
# if echo "$LABELS" | grep -q "release-apply"; then
# echo "Label 'release-apply' found."
# # PRs with label "release-label" are created at the end of this workflow and we don't want infinite loops
# echo "The pull request is merged and has the 'release-apply' label. Nothing to do. Exiting with success"
# echo "continue=false" >>$GITHUB_OUTPUT
# exit 0
# else
# echo "Label 'release-apply' not found."
# echo "continue=true" >>$GITHUB_OUTPUT
# fi
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# - name: check for changes in helm-chart directory
# id: check_changes
# run: |
# git fetch --all
# # check for changes between HEAD and previous commit in a specific directory
# if ! git diff --quiet HEAD~ -- ./helm-chart/eoapi/; then
# echo "Changes detected in the ./helm-chart/eoapi/ directory."
# echo "continue=true" >> $GITHUB_OUTPUT
# else
# echo "No changes detected in the ./helm-chart/eoapi directory. Exiting."
# echo "continue=false" >> $GITHUB_OUTPUT
# exit 0
# fi
#
# - name: determine version increment
# if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true'
# id: determine-version
# run: |
# PR_TITLE=$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]')
# if [[ "$PR_TITLE" =~ "major:" ]]; then
# echo "version_type=major" >> $GITHUB_ENV
# elif [[ "$PR_TITLE" =~ "minor:" ]]; then
# echo "version_type=minor" >> $GITHUB_ENV
# else
# echo "version_type=patch" >> $GITHUB_ENV
# fi
# echo "Version increment type: ${{ env.version_type }}"
#
# - name: bump chart versions
# if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true'
# id: bump-version
# run: |
# cd helm-chart/eoapi
# VERSION_TYPE=${{ env.version_type }}
#
# CURRENT_VERSION=$(grep '^version:' Chart.yaml | awk '{print $2}')
# # strip double quotes
# CURRENT_VERSION=${CURRENT_VERSION#\"}
# CURRENT_VERSION=${CURRENT_VERSION%\"}
#
# CURRENT_APP_VERSION=$(grep '^appVersion:' Chart.yaml | awk '{print $2}')
# # strip double quotes
# CURRENT_APP_VERSION=${CURRENT_APP_VERSION#\"}
# CURRENT_APP_VERSION=${CURRENT_APP_VERSION%\"}
#
# IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION"
# IFS='.' read -r -a APP_VERSION_PARTS <<< "$CURRENT_APP_VERSION"
#
# if [[ "$VERSION_TYPE" == "major" ]]; then
# NEW_VERSION="$((VERSION_PARTS[0] + 1)).0.0"
# # appVersion does not need to follow semvar
# NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))"
# elif [[ "$VERSION_TYPE" == "minor" ]]; then
# NEW_VERSION="${VERSION_PARTS[0]}.$((VERSION_PARTS[1] + 1)).0"
# # appVersion does not need to follow semvar
# NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))"
# else
# NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$((VERSION_PARTS[2] + 1))"
# # appVersion does not need to follow semvar
# NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))"
# fi
#
# # export so strenv picks them up
# export NEW_VERSION
# export NEW_APP_VERSION
#
# yq -i '.version = strenv(NEW_VERSION)' Chart.yaml
# yq -i '.appVersion = strenv(NEW_APP_VERSION)' Chart.yaml
#
# echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
# echo "New version: $NEW_VERSION"
# echo "New app version: $NEW_APP_VERSION"
#
# - uses: actions/github-script@v6
# if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true'
# id: create_pr
# uses: peter-evans/create-pull-request@v6
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# commit-message: 'release eoapi chart to v${{ env.new_version }}'
# title: 'release v${{ env.new_version }} for ${{ github.ref }}@${{ github.sha }}'
# body: |
# this PR contains the version bumps for the eoapi chart v${{ env.new_version }}
# base: main
# branch: apply-${{ github.head_ref }}
# labels: release-apply
# script: |
# github.rest.issues.addLabels({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: context.issue.number,
# labels: ['release-apply']
# })
#
# - name: commit chart version bump
# if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true'
# run: |
# TAG="v${{ env.new_version }}"
# git config --global user.name "${{ github.actor }}"
# git config --global user.email "${{ github.actor }}@users.noreply.github.com"
# git fetch origin
# git checkout ${{ github.head_ref }}
# git add -A
# git commit -m "release version to v${{ env.new_version }}"
# # only tag main branch in manual release
# # git tag "v${{ env.new_version }}"
# git push origin ${{ github.head_ref }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
## - name: create pr
## if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true'
## id: create_pr
## uses: peter-evans/create-pull-request@v6
## with:
## token: ${{ secrets.GITHUB_TOKEN }}
## commit-message: 'release eoapi chart to v${{ env.new_version }}'
## title: 'release v${{ env.new_version }} for ${{ github.ref }}@${{ github.sha }}'
## body: |
## this PR contains the version bumps for the eoapi chart v${{ env.new_version }}
## base: main
## branch: apply-${{ github.head_ref }}
## labels: release-apply
18 changes: 8 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
name: release helm chart

#on:
# release:
# types:
# - published

on:
push:
branches:
- main
release:
types:
- published

env:
HELM_VERSION: v3.15.2

jobs:
release:
if: github.actor == 'ranchodeluxe' || github.actor == 'gcorradini' || github.actor == 'sunu' || github.actor == 'ividito'
if: "!startsWith(github.ref, 'refs/tags/eoapi-')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -50,12 +45,15 @@ jobs:
helm repo list
- name: run chart-releaser
uses: helm/chart-releaser-action@v1.4.0
uses: helm/chart-releaser-action@v1.6.1
with:
charts_dir: helm-chart
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: true
CR_PACKAGE_PATH: "."
CR_INDEX_PATH: "."


# - name: helm release packages
# env:
Expand Down
3 changes: 2 additions & 1 deletion helm-chart/eoapi/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
tmp/
tmp/
Chart.lock
9 changes: 0 additions & 9 deletions helm-chart/eoapi/Chart.lock

This file was deleted.

0 comments on commit e4f7421

Please sign in to comment.