Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 lint workflows before merge #71

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ on:
- '**.md'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- run: go install github.com/rhysd/actionlint/cmd/actionlint@latest
- run: |
GOPATH="$(go env GOPATH)"
export PATH="${PATH}:${GOPATH}/bin"
actionlint
tests:
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build-push-images.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Push Image
name: Reusable Build and Push Image

on:
workflow_call:
Expand Down Expand Up @@ -114,11 +114,11 @@ jobs:
- name: Create manifest
shell: bash
run: |
podman manifest create ${{ inputs.registry }}/${{ inputs.image_name }}:${{ env.tag }}
podman manifest create "${{ inputs.registry }}/${{ inputs.image_name }}:${{ env.tag }}"
for arch in $(echo '${{ inputs.architectures }}' | jq -r '.[]'); do
podman manifest add \
${{ inputs.registry }}/${{ inputs.image_name }}:${{ env.tag }} \
${{ inputs.registry }}/${{ inputs.image_name }}:${{ env.tag }}-${arch}
"${{ inputs.registry }}/${{ inputs.image_name }}:${{ env.tag }}" \
"${{ inputs.registry }}/${{ inputs.image_name }}:${{ env.tag }}-${arch}"
done

- name: Push To Quay
Expand Down
38 changes: 17 additions & 21 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create release
name: Reusable Create release

on:
workflow_call:
Expand Down Expand Up @@ -39,19 +39,19 @@ jobs:
fi

if [[ "${{ inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
fi

if [[ "${{ inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then
echo "is_dotzero=true" >> $GITHUB_OUTPUT
echo "is_dotzero=true" >> "$GITHUB_OUTPUT"
else
echo "is_dotzero=false" >> $GITHUB_OUTPUT
echo "is_dotzero=false" >> "$GITHUB_OUTPUT"
fi

XY_VERSION=$(echo ${{ inputs.version }} | awk -F. '{print substr($1,2)"."$2}')
echo "xy_version=${XY_VERSION}" >> $GITHUB_OUTPUT
echo "xy_version=${XY_VERSION}" >> "$GITHUB_OUTPUT"
id: check_tag

- name: Checkout code
Expand All @@ -70,41 +70,37 @@ jobs:

# Details we need in order to create the release
REPOSITORY=${{ inputs.repository }}
echo "owner=${REPOSITORY%/*}" >> $GITHUB_OUTPUT
echo "repo=${REPOSITORY#*/}" >> $GITHUB_OUTPUT
echo "owner=${REPOSITORY%/*}" >> "$GITHUB_OUTPUT"
echo "repo=${REPOSITORY#*/}" >> "$GITHUB_OUTPUT"
SHA=$(git rev-parse HEAD)
echo "sha=${SHA}" >> $GITHUB_OUTPUT
echo "sha=${SHA}" >> "$GITHUB_OUTPUT"

# Always compare to latest published full release for repository
PREV_TAG=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ inputs.repository }}/releases/latest | jq -r '.tag_name')
filterfunc() { git log --pretty=format:%s ${PREV_TAG}..HEAD | grep "^\s*:$1:" | sed "s/^\s*:$1:\s*/ * /"; }
filterfunc() { git log --pretty=format:%s "${PREV_TAG}..HEAD" | grep "^\s*:$1:" | sed "s/^\s*:$1:\s*/ * /"; }
# Handle scenario where no previous tag exists
if [ -z "${PREV_TAG}" ]; then
filterfunc() { git log --pretty=format:%s | grep "^\s*:$1:" | sed "s/^\s*:$1:\s*/ * /"; }
fi

RELEASE_DOC="${PWD}/release.md"
echo "release_doc=${RELEASE_DOC}" >> $GITHUB_ENV
echo "release_doc=${RELEASE_DOC}" >> "$GITHUB_ENV"

BREAKING_CHANGES="$(filterfunc warning)"
if [ -n "${BREAKING_CHANGES}" ]; then
echo "## :warning: Breaking Changes" >> ${RELEASE_DOC}
echo "${BREAKING_CHANGES}" >> ${RELEASE_DOC}
echo "" >> ${RELEASE_DOC}
echo -e "## :warning: Breaking Changes\n${BREAKING_CHANGES}\n\n" >> "${RELEASE_DOC}"
# echo "${BREAKING_CHANGES}" >> "${RELEASE_DOC}"
# echo "" >> "${RELEASE_DOC}"
fi

FEATURE_CHANGES="$(filterfunc sparkles)"
if [ -n "${FEATURE_CHANGES}" ]; then
echo "## :sparkles: Features" >> ${RELEASE_DOC}
echo "${FEATURE_CHANGES}" >> ${RELEASE_DOC}
echo "" >> ${RELEASE_DOC}
echo -e "## :sparkles: Features\n${FEATURE_CHANGES}\n\n" >> "${RELEASE_DOC}"
fi

BUG_FIXES="$(filterfunc bug)"
if [ -n "${BUG_FIXES}" ]; then
echo "## :bug: Bug Fixes" >> ${RELEASE_DOC}
echo "${BUG_FIXES}" >> ${RELEASE_DOC}
echo "" >> ${RELEASE_DOC}
echo -e "## :bug: Bug Fixes\n${BUG_FIXES}\n\n" >> "${RELEASE_DOC}"
fi

# Add contributors as GitHub would have added them
Expand All @@ -115,7 +111,7 @@ jobs:
/repos/${{ inputs.repository }}/releases/generate-notes \
-f tag_name="${{ inputs.version }}" \
-f target_commitish="${{ inputs.ref }}" \
-f previous_tag_name="${PREV_TAG}" | jq -r '.body' | grep -Pzo '.*Contributors(.*\n)*' >> ${RELEASE_DOC}
-f previous_tag_name="${PREV_TAG}" | jq -r '.body' | grep -Pzo '.*Contributors(.*\n)*' >> "${RELEASE_DOC}"

# TODO(djzager): More? could make this workflow accept as an argument whether or not
# to include other types (ie. seedling, docs)
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/prep-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# - updates specified base images used in the Dockerfile to use the right tags
# - updates specified go dependencies in go.mod file to point to right branches
# - commits the results back to the originating branch
name: Prepare repository for release
name: Reusable Prepare repository for release
on:
workflow_call:
inputs:
Expand Down Expand Up @@ -33,10 +33,10 @@ jobs:
id: extract-info
run: |
if [[ "${BRANCH_REF}" =~ ^refs/heads/release-[0-9]+.[0-9]+$ ]]; then
BRANCH=$(echo "$BRANCH_REF" | sed "s,refs/heads/,,")
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
BRANCH="${BRANCH_REF##refs/heads/}"
echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT"
else
echo "branch=NOOP" >> $GITHUB_OUTPUT
echo "branch=NOOP" >> "$GITHUB_OUTPUT"
fi
env:
BRANCH_REF: ${{ inputs.branch_ref }}
Expand All @@ -48,8 +48,8 @@ jobs:
- name: Update tags of base images in Dockerfile
if: steps.extract-info.outputs.branch != 'NOOP'
run: |
for REPLACE_IMAGE in $(echo "$REPLACE_IMAGES" | jq -r '.[]'); do
sed -i "s,${REPLACE_IMAGE}.*$,${REPLACE_IMAGE}:${TAG}," ${DOCKERFILE}
for IMAGE in $(echo "$REPLACE_IMAGES" | jq -r '.[]'); do
sed -i "s,${IMAGE}.*$,${IMAGE}:${TAG}," "${DOCKERFILE}"
done
env:
REPLACE_IMAGES: ${{ inputs.images_to_update }}
Expand All @@ -59,8 +59,8 @@ jobs:
- name: Update dependency versions in go mod file
if: steps.extract-info.outputs.branch != 'NOOP'
run: |
for REPLACE_DEP in $(echo "$REPLACE_DEPS" | jq -r '.[]'); do
go get ${REPLACE_DEP}@${BRANCH}
for DEP in $(echo "$REPLACE_DEPS" | jq -r '.[]'); do
go get "${DEP}@${BRANCH}"
done
go mod tidy
env:
Expand Down
Loading