Skip to content

Commit

Permalink
workflows update
Browse files Browse the repository at this point in the history
  • Loading branch information
ssyno committed Aug 7, 2024
1 parent 08f4f83 commit 39701b5
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 271 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/zz_generated.check_values_schema.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT EDIT. Generated with:
#
# devctl@6.21.0
# devctl@6.23.3
#
name: 'Values and schema'
on:
Expand All @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

Expand Down
190 changes: 91 additions & 99 deletions .github/workflows/zz_generated.create_release.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT EDIT. Generated with:
#
# devctl gen workflows
# devctl@6.23.3
#
name: Create Release
on:
Expand All @@ -15,7 +15,7 @@ on:
jobs:
debug_info:
name: Debug info
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- name: Print github context JSON
run: |
Expand All @@ -24,33 +24,35 @@ jobs:
EOF
gather_facts:
name: Gather facts
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
outputs:
project_go_path: ${{ steps.get_project_go_path.outputs.path }}
ref_version: ${{ steps.ref_version.outputs.refversion }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version
id: get_version
env:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
title="$(echo "${{ github.event.head_commit.message }}" | head -n 1 -)"
title=$(echo -n "${COMMIT_MESSAGE}" | head -1)
# Matches strings like:
#
# - "release v1.2.3"
# - "release v1.2.3-r4"
# - "release v1.2.3 (#56)"
# - "release v1.2.3-r4 (#56)"
# - "Release v1.2.3"
# - "Release v1.2.3-r4"
# - "Release v1.2.3 (#56)"
# - "Release v1.2.3-r4 (#56)"
#
# And outputs version part (1.2.3).
if echo $title | grep -qE '^release v[0-9]+\.[0-9]+\.[0-9]+([.-][^ .-][^ ]*)?( \(#[0-9]+\))?$' ; then
version=$(echo $title | cut -d ' ' -f 2)
if echo "${title}" | grep -iqE '^Release v[0-9]+\.[0-9]+\.[0-9]+([.-][^ .-][^ ]*)?( \(#[0-9]+\))?$' ; then
version=$(echo "${title}" | cut -d ' ' -f 2)
fi
version="${version#v}" # Strip "v" prefix.
echo "version=\"$version\""
echo "::set-output name=version::${version}"
echo "version=\"${version}\""
echo "version=${version}" >> $GITHUB_OUTPUT
- name: Checkout code
if: ${{ steps.get_version.outputs.version != '' }}
uses: actions/checkout@v2
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Get project.go path
id: get_project_go_path
if: ${{ steps.get_version.outputs.version != '' }}
Expand All @@ -60,81 +62,46 @@ jobs:
path=''
fi
echo "path=\"$path\""
echo "::set-output name=path::${path}"
echo "path=${path}" >> $GITHUB_OUTPUT
- name: Check if reference version
id: ref_version
env:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
title="$(echo "${{ github.event.head_commit.message }}" | head -n 1 -)"
if echo $title | grep -qE '^release v[0-9]+\.[0-9]+\.[0-9]+([.-][^ .-][^ ]*)?( \(#[0-9]+\))?$' ; then
version=$(echo $title | cut -d ' ' -f 2)
title=$(echo -n "${COMMIT_MESSAGE}" | head -1)
if echo "${title}" | grep -qE '^release v[0-9]+\.[0-9]+\.[0-9]+([.-][^ .-][^ ]*)?( \(#[0-9]+\))?$' ; then
version=$(echo "${title}" | cut -d ' ' -f 2)
fi
version=$(echo $title | cut -d ' ' -f 2)
version=$(echo "${title}" | cut -d ' ' -f 2)
version="${version#v}" # Strip "v" prefix.
refversion=false
if [[ "${version}" =~ ^[0-9]+.[0-9]+.[0-9]+-[0-9]+$ ]]; then
refversion=true
fi
echo "refversion =\"$refversion\""
echo "::set-output name=refversion::$refversion"
install_semver:
name: Install semver
runs-on: ubuntu-18.04
env:
BINARY: "semver"
URL: "https://raw.githubusercontent.com/fsaintjacques/semver-tool/3.0.0/src/semver"
steps:
- name: Key
id: key
run: |
cache_dir="/opt/cache"
cache_key="install-${BINARY}-${URL}"
echo "::set-output name=binary::${BINARY}"
echo "::set-output name=cache_dir::${cache_dir}"
echo "::set-output name=cache_key::${cache_key}"
echo "::set-output name=url::${URL}"
- name: Cache
id: cache
uses: actions/cache@v1
with:
key: "${{ steps.key.outputs.cache_key }}"
path: "${{ steps.key.outputs.cache_dir }}"
- name: Download
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: |
# TODO check hash
binary="${{ steps.key.outputs.binary }}"
cache_dir="${{ steps.key.outputs.cache_dir }}"
url="${{ steps.key.outputs.url }}"
mkdir $cache_dir
curl -fsSLo $cache_dir/$binary $url
chmod +x $cache_dir/$binary
- name: Smoke test
run: |
${{ steps.key.outputs.cache_dir }}/${{ steps.key.outputs.binary }} --version
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: "${{ steps.key.outputs.binary }}"
path: "${{ steps.key.outputs.cache_dir }}/${{ steps.key.outputs.binary }}"
echo "refversion =\"${refversion}\""
echo "refversion=${refversion}" >> $GITHUB_OUTPUT
update_project_go:
name: Update project.go
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
if: ${{ needs.gather_facts.outputs.version != '' && needs.gather_facts.outputs.project_go_path != '' && needs.gather_facts.outputs.ref_version != 'true' }}
needs:
- gather_facts
- install_semver
steps:
- name: Download semver artifact to /opt/bin
uses: actions/download-artifact@v2
- name: Install architect
uses: giantswarm/install-binary-action@c37eb401e5092993fc76d545030b1d1769e61237 # v3.0.0
with:
name: semver
path: /opt/bin
- name: Prepare /opt/bin
run: |
chmod +x /opt/bin/*
echo "::add-path::/opt/bin"
binary: "architect"
version: "6.14.1"
- name: Install semver
uses: giantswarm/install-binary-action@c37eb401e5092993fc76d545030b1d1769e61237 # v3.0.0
with:
binary: "semver"
version: "3.2.0"
download_url: "https://github.com/fsaintjacques/${binary}-tool/archive/${version}.tar.gz"
tarball_binary_path: "*/src/${binary}"
smoke_test: "${binary} --version"
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Update project.go
id: update_project_go
env:
Expand All @@ -145,45 +112,56 @@ jobs:
version="${{ needs.gather_facts.outputs.version }}"
new_version="$(semver bump patch $version)-dev"
echo "version=\"$version\" new_version=\"$new_version\""
echo "::set-output name=new_version::${new_version}"
echo "new_version=${new_version}" >> $GITHUB_OUTPUT
sed -Ei "s/(version[[:space:]]*=[[:space:]]*)\"${version}\"/\1\"${new_version}\"/" $file
if git diff --exit-code $file ; then
echo "error: no changes in \"$file\"" >&2
exit 1
fi
- name: Set up git identity
run: |
git config --local user.email "[email protected]"
git config --local user.name "taylorbot"
- name: Commit changes
run: |
file="${{ needs.gather_facts.outputs.project_go_path }}"
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add $file
git commit -m "Bump version to ${{ steps.update_project_go.outputs.new_version }}"
- name: Push changes
env:
REMOTE_REPO: "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
REMOTE_REPO: "https://${{ github.actor }}:${{ secrets.TAYLORBOT_GITHUB_ACTION }}@github.com/${{ github.repository }}.git"
branch: "${{ github.ref }}-version-bump"
run: |
git push "${REMOTE_REPO}" HEAD:${{ env.branch }}
- name: Create PR
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}"
base: "${{ github.ref }}"
branch: "${{ github.ref }}-version-bump"
version: "${{ needs.gather_facts.outputs.version }}"
title: "Bump version to ${{ steps.update_project_go.outputs.new_version }}"
run: |
hub pull-request -f -m "${{ env.title }}" -b ${{ env.base }} -h ${{ env.branch }} -r ${{ github.actor }}
gh pr create --title "${{ env.title }}" --body "" --base ${{ env.base }} --head ${{ env.branch }} --reviewer ${{ github.actor }}
- name: Enable auto-merge for PR
env:
GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}"
base: "${{ github.ref }}"
branch: "${{ github.ref }}-version-bump"
version: "${{ needs.gather_facts.outputs.version }}"
title: "Bump version to ${{ steps.update_project_go.outputs.new_version }}"
run: |
gh pr merge --auto --squash "${{ env.branch }}" || echo "::warning::Auto-merge not allowed. Please adjust the repository settings."
create_release:
name: Create release
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs:
- gather_facts
if: ${{ needs.gather_facts.outputs.version }}
outputs:
upload_url: ${{ steps.create_gh_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ github.sha }}
- name: Ensure correct version in project.go
Expand All @@ -192,52 +170,66 @@ jobs:
file="${{ needs.gather_facts.outputs.project_go_path }}"
version="${{ needs.gather_facts.outputs.version }}"
grep -qE "version[[:space:]]*=[[:space:]]*\"$version\"" $file
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@32aa5b4c155d76c94e4ec883a223c947b2f02656 # v2.2.3
with:
version: ${{ needs.gather_facts.outputs.version }}
path: ./CHANGELOG.md
- name: Set up git identity
run: |
git config --local user.email "[email protected]"
git config --local user.name "taylorbot"
- name: Create tag
run: |
version="${{ needs.gather_facts.outputs.version }}"
git config --local user.name "github-actions"
git tag "v$version" ${{ github.sha }}
- name: Push tag
env:
REMOTE_REPO: "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
REMOTE_REPO: "https://${{ github.actor }}:${{ secrets.TAYLORBOT_GITHUB_ACTION }}@github.com/${{ github.repository }}.git"
run: |
git push "${REMOTE_REPO}" --tags
- name: Create release
id: create_gh_release
uses: actions/create-release@v1
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}"
with:
tag_name: "v${{ needs.gather_facts.outputs.version }}"
release_name: "v${{ needs.gather_facts.outputs.version }}"
body: ${{ steps.changelog_reader.outputs.changes }}
tag: "v${{ needs.gather_facts.outputs.version }}"

create-release-branch:
name: Create release branch
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs:
- gather_facts
- install_semver
if: ${{ needs.gather_facts.outputs.version }}
steps:
- name: Download semver artifact to /opt/bin
uses: actions/download-artifact@v2
- name: Install semver
uses: giantswarm/install-binary-action@c37eb401e5092993fc76d545030b1d1769e61237 # v3.0.0
with:
name: semver
path: /opt/bin
- name: Prepare /opt/bin
run: |
chmod +x /opt/bin/*
echo "::add-path::/opt/bin"
- uses: actions/checkout@v2
name: Check out the repository
binary: "semver"
version: "3.0.0"
download_url: "https://github.com/fsaintjacques/${binary}-tool/archive/${version}.tar.gz"
tarball_binary_path: "*/src/${binary}"
smoke_test: "${binary} --version"
- name: Check out the repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0 # Clone the whole history, not just the most recent commit.
- name: Fetch all tags and branches
run: "git fetch --all"
- name: Create long-lived release branch
run: |
current_version="${{ needs.gather_facts.outputs.version }}"
parent_version="$(git describe --tags --abbrev=0 HEAD^)"
parent_version="$(git describe --tags --abbrev=0 HEAD^ || true)"
parent_version="${parent_version#v}" # Strip "v" prefix.
if [[ -z "$parent_version" ]] ; then
echo "Unable to find a parent tag version. No branch to create."
exit 0
fi
echo "current_version=$current_version parent_version=$parent_version"
current_major=$(semver get major $current_version)
Expand All @@ -264,4 +256,4 @@ jobs:
fi
git branch $release_branch HEAD^
git push origin $release_branch
git push origin $release_branch
Loading

0 comments on commit 39701b5

Please sign in to comment.