diff --git a/.github/workflows/_main.yml b/.github/workflows/_main.yml index 3a10b00..b59f16e 100644 --- a/.github/workflows/_main.yml +++ b/.github/workflows/_main.yml @@ -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: diff --git a/.github/workflows/build-push-images.yaml b/.github/workflows/build-push-images.yaml index 2a8990c..94507ba 100644 --- a/.github/workflows/build-push-images.yaml +++ b/.github/workflows/build-push-images.yaml @@ -1,4 +1,4 @@ -name: Build and Push Image +name: Reusable Build and Push Image on: workflow_call: @@ -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 diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 0350865..a8e1575 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -1,4 +1,4 @@ -name: Create release +name: Reusable Create release on: workflow_call: @@ -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 @@ -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 @@ -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) diff --git a/.github/workflows/prep-release.yaml b/.github/workflows/prep-release.yaml index 952f816..c2b9a1f 100644 --- a/.github/workflows/prep-release.yaml +++ b/.github/workflows/prep-release.yaml @@ -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: @@ -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 }} @@ -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 }} @@ -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: