Skip to content

Commit

Permalink
Align files (#34)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
architectbot and actions-user authored Nov 6, 2020
1 parent ee5ba8e commit 6eeb294
Show file tree
Hide file tree
Showing 7 changed files with 479 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# DO NOT EDIT. Generated with:
#
# devctl gen dependabot
#
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: weekly
time: "04:00"
open-pull-requests-limit: 10
ignore:
- dependency-name: k8s.io/*
versions:
- ">=0.19.0"
227 changes: 227 additions & 0 deletions .github/workflows/zz_generated.create_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
# DO NOT EDIT. Generated with:
#
# devctl gen workflows
#
name: Create Release
on:
push:
branches:
- 'legacy'
- 'master'
- 'release-v*.*.x'
# "!" negates previous positive patterns so it has to be at the end.
- '!release-v*.x.x'
jobs:
debug_info:
name: Debug info
runs-on: ubuntu-20.04
steps:
- name: Print github context JSON
run: |
cat <<EOF
${{ toJson(github) }}
EOF
gather_facts:
name: Gather facts
runs-on: ubuntu-20.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
run: |
title="$(echo "${{ github.event.head_commit.message }}" | head -n 1 -)"
# Matches strings like:
#
# - "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 -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}"
- name: Checkout code
if: ${{ steps.get_version.outputs.version != '' }}
uses: actions/checkout@v2
- name: Get project.go path
id: get_project_go_path
if: ${{ steps.get_version.outputs.version != '' }}
run: |
path='./pkg/project/project.go'
if [[ ! -f $path ]] ; then
path=''
fi
echo "path=\"$path\""
echo "::set-output name=path::${path}"
- name: Check if reference version
id: ref_version
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)
fi
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"
update_project_go:
name: Update project.go
runs-on: ubuntu-20.04
if: ${{ needs.gather_facts.outputs.version != '' && needs.gather_facts.outputs.project_go_path != '' && needs.gather_facts.outputs.ref_version != 'true' }}
needs:
- gather_facts
steps:
- name: Install architect
uses: giantswarm/[email protected]
with:
binary: "architect"
version: "3.0.5"
- name: Install semver
uses: giantswarm/[email protected]
with:
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: Checkout code
uses: actions/checkout@v2
- name: Update project.go
id: update_project_go
env:
branch: "${{ github.ref }}-version-bump"
run: |
git checkout -b ${{ env.branch }}
file="${{ needs.gather_facts.outputs.project_go_path }}"
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}"
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: 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"
branch: "${{ github.ref }}-version-bump"
run: |
git push "${REMOTE_REPO}" HEAD:${{ env.branch }}
- name: Create PR
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
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 }}
create_release:
name: Create release
runs-on: ubuntu-20.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
with:
ref: ${{ github.sha }}
- name: Ensure correct version in project.go
if: ${{ needs.gather_facts.outputs.project_go_path != '' && needs.gather_facts.outputs.ref_version != 'true' }}
run: |
file="${{ needs.gather_facts.outputs.project_go_path }}"
version="${{ needs.gather_facts.outputs.version }}"
grep -qE "version[[:space:]]*=[[:space:]]*\"$version\"" $file
- 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"
run: |
git push "${REMOTE_REPO}" --tags
- name: Create release
id: create_gh_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ needs.gather_facts.outputs.version }}"
release_name: "v${{ needs.gather_facts.outputs.version }}"
create-release-branch:
name: Create release branch
runs-on: ubuntu-20.04
needs:
- gather_facts
if: ${{ needs.gather_facts.outputs.version }}
steps:
- name: Install semver
uses: giantswarm/[email protected]
with:
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@v2
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="${parent_version#v}" # Strip "v" prefix.
echo "current_version=$current_version parent_version=$parent_version"
current_major=$(semver get major $current_version)
current_minor=$(semver get minor $current_version)
parent_major=$(semver get major $parent_version)
parent_minor=$(semver get minor $parent_version)
echo "current_major=$current_major current_minor=$current_minor parent_major=$parent_major parent_minor=$parent_minor"
if [[ $current_major -gt $parent_major ]] ; then
echo "Current tag is a new major version"
elif [[ $current_major -eq $parent_major ]] && [[ $current_minor -gt $parent_minor ]] ; then
echo "Current tag is a new minor version"
else
echo "Current tag is not a new major or minor version. Nothing to do here."
exit 0
fi
release_branch="release-v${parent_major}.${parent_minor}.x"
echo "release_branch=$release_branch"
if git rev-parse --verify $release_branch ; then
echo "Release branch $release_branch already exists. Nothing to do here."
exit 0
fi
git branch $release_branch HEAD^
git push origin $release_branch
94 changes: 94 additions & 0 deletions .github/workflows/zz_generated.create_release_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# DO NOT EDIT. Generated with:
#
# devctl gen workflows
#
name: Create Release PR
on:
push:
branches:
- 'master#release#v*.*.*'
- 'legacy#release#v*.*.*'
- 'release-v*.*.x#release#v*.*.*'
# "!" negates previous positive patterns so it has to be at the end.
- '!release-v*.x.x#release#v*.*.*'
jobs:
debug_info:
name: Debug info
runs-on: ubuntu-20.04
steps:
- name: Print github context JSON
run: |
cat <<EOF
${{ toJson(github) }}
EOF
gather_facts:
name: Gather facts
runs-on: ubuntu-20.04
outputs:
base: ${{ steps.gather_facts.outputs.base }}
skip: ${{ steps.pr_exists.outputs.skip }}
version: ${{ steps.gather_facts.outputs.version }}
steps:
- name: Gather facts
id: gather_facts
run: |
head="${{ github.event.ref }}"
head="${head#refs/heads/}" # Strip "refs/heads/" prefix.
base="$(echo $head | cut -d '#' -f 1)"
base="${base#refs/heads/}" # Strip "refs/heads/" prefix.
version="$(echo $head | cut -d '#' -f 3)"
version="${version#v}" # Strip "v" prefix.
echo "base=\"$base\" head=\"$head\" version=\"$version\""
echo "::set-output name=base::${base}"
echo "::set-output name=head::${head}"
echo "::set-output name=version::${version}"
- name: Check if PR exists
id: pr_exists
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
if gh pr view --repo ${{ github.repository }} ${{ github.event.ref }} ; then
echo "::warning::Release PR already exists"
echo "::set-output name=skip::true"
else
echo "::set-output name=skip::false"
fi
create_release_pr:
name: Create release PR
runs-on: ubuntu-20.04
needs:
- gather_facts
if: ${{ needs.gather_facts.outputs.skip != 'true' }}
env:
architect_flags: "--organisation ${{ github.repository_owner }} --project ${{ github.event.repository.name }}"
steps:
- name: Install architect
uses: giantswarm/[email protected]
with:
binary: "architect"
version: "3.0.5"
- name: Checkout code
uses: actions/checkout@v2
- name: Prepare release changes
run: |
architect prepare-release ${{ env.architect_flags }} --version "${{ needs.gather_facts.outputs.version }}"
- name: Create release commit
env:
version: "${{ needs.gather_facts.outputs.version }}"
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
git add -A
git commit -m "Release v${{ env.version }}"
- name: Push changes
env:
remote_repo: "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
run: |
git push "${remote_repo}" HEAD:${{ github.ref }}
- name: Create PR
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
base: "${{ needs.gather_facts.outputs.base }}"
version: "${{ needs.gather_facts.outputs.version }}"
run: |
hub pull-request -f -m "Release v${{ env.version }}" -a ${{ github.actor }} -b ${{ env.base }} -h ${{ github.event.ref }}
44 changes: 44 additions & 0 deletions .github/workflows/zz_generated.gomodtidy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# DO NOT EDIT. Generated with:
#
# devctl gen dependabot
#
# Credit: https://github.com/crazy-max/diun
name: auto-go-mod-tidy

on:
push:
branches:
- 'dependabot/**'

jobs:
fix:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v1
-
# https://github.com/actions/checkout/issues/6
name: Fix detached HEAD
run: git checkout ${GITHUB_REF#refs/heads/}
-
name: Tidy
run: |
rm -f go.sum
go mod tidy
-
name: Set up Git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
-
name: Commit and push changes
run: |
git add .
if output=$(git status --porcelain) && [ ! -z "$output" ]; then
git commit -m 'Fix go modules'
git push
fi
Loading

0 comments on commit 6eeb294

Please sign in to comment.