diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a975232..1230149 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,3 @@ -# Please see the documentation for all configuration options: -# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - version: 2 updates: - package-ecosystem: "github-actions" diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 0000000..aec8fd5 --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1,3 @@ +{ + "line-length": false +} diff --git a/.github/workflows/add-labels-standardized.yaml b/.github/workflows/add-labels-standardized.yaml index c20a712..1360a67 100644 --- a/.github/workflows/add-labels-standardized.yaml +++ b/.github/workflows/add-labels-standardized.yaml @@ -1,4 +1,4 @@ -name: 'add labels standardized' +name: add labels standardized on: issues: diff --git a/.github/workflows/add-to-project-factory-dependabot.yaml b/.github/workflows/add-to-project-factory-dependabot.yaml index d69ab7d..56f1cf4 100644 --- a/.github/workflows/add-to-project-factory-dependabot.yaml +++ b/.github/workflows/add-to-project-factory-dependabot.yaml @@ -1,14 +1,13 @@ -name: 'add to project factory dependabot' +name: add to project factory dependabot on: pull_request: branches: [main] jobs: - - add-issue-labels: + add-to-project-dependabot: secrets: SENZING_GITHUB_PROJECT_RW_TOKEN: ${{ secrets.SENZING_GITHUB_PROJECT_RW_TOKEN }} - uses: senzing-factory/build-resources/.github/workflows/add-to-project-dependabot.yaml@main + uses: senzing-factory/build-resources/.github/workflows/add-to-project-dependabot.yaml@v1 with: project: ${{ vars.SENZING_PROJECT_FACTORY }} diff --git a/.github/workflows/add-to-project-factory.yaml b/.github/workflows/add-to-project-factory.yaml index b2dd32d..e6bf67b 100644 --- a/.github/workflows/add-to-project-factory.yaml +++ b/.github/workflows/add-to-project-factory.yaml @@ -1,4 +1,4 @@ -name: 'add to project factory' +name: add to project factory on: issues: @@ -8,11 +8,12 @@ on: jobs: add-to-project: - name: Add issue to project + name: add issue to project runs-on: ubuntu-latest + steps: - - name: Assign issue to project + - name: assign issue to project uses: actions/add-to-project@v0.5.0 with: - project-url: https://github.com/orgs/${{ vars.SENZING_GITHUB_ACCOUNT_NAME }}/projects/${{ vars.SENZING_PROJECT_FACTORY }} github-token: ${{ secrets.SENZING_GITHUB_ACCESS_TOKEN }} + project-url: https://github.com/orgs/${{ vars.SENZING_GITHUB_ACCOUNT_NAME }}/projects/${{ vars.SENZING_PROJECT_FACTORY }} diff --git a/.github/workflows/lint-repo.yaml b/.github/workflows/lint-repo.yaml new file mode 100644 index 0000000..fbfb108 --- /dev/null +++ b/.github/workflows/lint-repo.yaml @@ -0,0 +1,11 @@ +name: lint repo + +on: + push: + branches-ignore: [main] + pull_request: + branches: [main] + +jobs: + lint-code-base: + uses: senzing-factory/build-resources/.github/workflows/linter.yaml@v1 diff --git a/.github/workflows/move-pr-to-done-dependabot.yaml b/.github/workflows/move-pr-to-done-dependabot.yaml new file mode 100644 index 0000000..3e98652 --- /dev/null +++ b/.github/workflows/move-pr-to-done-dependabot.yaml @@ -0,0 +1,14 @@ +name: move pr to done dependabot + +on: + pull_request: + branches: [main] + types: [closed] + +jobs: + move-pr-to-done-dependabot: + secrets: + SENZING_GITHUB_PROJECT_RW_TOKEN: ${{ secrets.SENZING_GITHUB_PROJECT_RW_TOKEN }} + uses: senzing-factory/build-resources/.github/workflows/move-pr-to-done-dependabot.yaml@v1 + with: + project: ${{ vars.SENZING_PROJECT_FACTORY }} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index f6f9f91..0dc166a 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -30,7 +30,7 @@ Project maintainers have the right and responsibility to remove, edit, or reject ## Scope -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement diff --git a/README.md b/README.md index 69ec557..7844901 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Make a github.go file. ## Overview -The github action creates a pull request with updated values in `github.go`. +The GitHub action creates a pull request with updated values in `github.go`. ## Usage @@ -62,6 +62,7 @@ The github action creates a pull request with updated values in `github.go`. file: example/example.go package: myexample ``` + 1. A `.github/workflows/make-go-github-file.yaml` file that creates a `cmd/github.go` file for "package cmd" using a signed commit. diff --git a/archive/entrypoint.sh.1680286896 b/archive/entrypoint.sh.1680286896 deleted file mode 100755 index 6a33e98..0000000 --- a/archive/entrypoint.sh.1680286896 +++ /dev/null @@ -1,257 +0,0 @@ -#!/bin/sh -set -eu - -# Function: write_file() - -write_file() { - echo "${FIRST_LINE}" > ${OUTFILE} - echo "// Created by make-go-version-file.yaml on $(date)" >> ${OUTFILE} - echo "package ${INPUT_PACKAGE}" >> ${OUTFILE} - echo "" >> ${OUTFILE} - echo "var githubDate string = \"${RELEASE_DATE}\"" >> ${OUTFILE} - echo "var githubIteration string = \"${RELEASE_ITERATION}\"" >> ${OUTFILE} - echo "var githubRef string = \"${GITHUB_REF}\"" >> ${OUTFILE} - echo "var githubRefName string = \"${GITHUB_REF_NAME}\"" >> ${OUTFILE} - echo "var githubRepository string = \"${GITHUB_REPOSITORY}\"" >> ${OUTFILE} - echo "var githubRepositoryName string = \"${RELEASE_REPOSITORY_NAME}\"" >> ${OUTFILE} - echo "var githubSha string = \"${GITHUB_SHA}\"" >> ${OUTFILE} - echo "var githubVersion string = \"${RELEASE_VERSION}\"" >> ${OUTFILE} - echo "" >> ${OUTFILE} -} - -#------------------------------------------------------------------------------ -# Main -#------------------------------------------------------------------------------ - -# Input parameters. - -INPUT_FILENAME=$1 -INPUT_PACKAGE=$2 - -echo " Input parameters: $@" -echo "Requested filename: ${INPUT_FILENAME}" -echo "Requested package: ${INPUT_PACKAGE}" - -# Apply hotfix for 'fatal: unsafe repository' error. - -git config --global --add safe.directory "${GITHUB_WORKSPACE}" - -# Required git configuration. - -git config user.name "${GITHUB_ACTOR}" -git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - -# Change directory to git repository. - -cd "${GITHUB_WORKSPACE}" || exit - -# Synthesize variables. - -RELEASE_REPOSITORY_NAME=$(basename ${GITHUB_REPOSITORY}) -RELEASE_VERSION=${GITHUB_REF_NAME} -RELEASE_ITERATION="0" -RELEASE_DATE=$(date +%Y-%m-%d) -OUTFILE="${GITHUB_WORKSPACE}/${INPUT_FILENAME}" -NEW_MAIN_BRANCH_NAME="make-go-version-file.yaml/main/${RELEASE_VERSION}" -NEW_TAG_BRANCH_NAME="make-go-version-file.yaml/tag/${RELEASE_VERSION}" - -# Check if file is already up-to-date. - -FIRST_LINE="// ${RELEASE_VERSION}" - -if [ -f ${OUTFILE} ]; then - EXISTING_FIRST_LINE=$(head -n 1 ${OUTFILE}) - if [ "${FIRST_LINE}" = "${EXISTING_FIRST_LINE}" ]; then - echo "${OUTFILE} is up to date. No changes needed." - exit 0 - fi -fi - -#------------------------------------------------------------------------------ -# Update the tagged version. -#------------------------------------------------------------------------------ - -# Get information from new release then delete the release. - -RELEASE_BODY=$(gh release view --json body | jq -r .body) -RELEASE_NAME=$(gh release view --json name | jq -r .name) -RELEASE_TAGNAME=$(gh release view --json tagName | jq -r .tagName) - -echo "-------------------------------------------------------------------------" -echo "-- Status --" -echo "-------------------------------------------------------------------------" - -echo " RELEASE_BODY: ${RELEASE_BODY}" -echo " RELEASE_NAME: ${RELEASE_NAME}" -echo "RELEASE_TAGNAME: ${RELEASE_TAGNAME}" - -echo ">>>>>>>> git status ----------------------------------------------------" -git status - -echo ">>>>>>>> git tag --list ------------------------------------------------" -git tag --list - -echo ">>>>>>>> git branch --list ---------------------------------------------" -git branch --list - -echo ">>>>>>>> gh pr list -----------------------------------------------------" -gh pr list - -echo ">>>>>>>> gh release view -----------------------------------------------" -gh release view - -echo ">>>>>>>> env | grep GITHUB_ | sort --------------------------------------" -env | grep "GITHUB_" | sort - -echo "-------------------------------------------------------------------------" -echo "-- Xxxxx --" -echo "-------------------------------------------------------------------------" - -echo ">>>>>>>> gh release delete \"${RELEASE_VERSION}\" --cleanup-tag --------" -gh release delete \ - "${RELEASE_VERSION}" \ - --cleanup-tag \ - --yes - -echo ">>>>>>>> git tag --list ------------------------------------------------" -git tag --list - -echo ">>>>>>>> git branch --list ---------------------------------------------" -git branch --list - -# Make a new branch. - -echo ">>>>>>>> git branch \"${NEW_TAG_BRANCH_NAME}\" \"${GITHUB_REF_NAME}\" --" -git branch "${NEW_TAG_BRANCH_NAME}" "${GITHUB_REF_NAME}" -git status - -echo ">>>>>>>> git branch --list ---------------------------------------------" -git branch --list - -echo ">>>>>>>> git checkout \"${NEW_TAG_BRANCH_NAME}\" -----------------------" -git checkout "${NEW_TAG_BRANCH_NAME}" -git status - -# Write the file into the branch. - -write_file - -# Inspect the file. - -echo "" -echo "Contents of ${OUTFILE}:" -echo "" -cat ${OUTFILE} - -# Commit the file to the branch and push branch to origin. - -echo ">>>>>>>> git add ${OUTFILE} --------------------------------------------" -git add ${OUTFILE} -git status - -echo ">>>>>>>> git commit -m \"make-go-version-file.yaml updated ${INPUT_FILENAME} for versioned release: ${RELEASE_VERSION}\"" -git commit -m "make-go-version-file.yaml updated ${INPUT_FILENAME} for versioned release: ${RELEASE_VERSION}" -git status - -echo ">>>>>>>> git push --set-upstream origin \"${NEW_TAG_BRANCH_NAME}\" -----" -git push --set-upstream origin "${NEW_TAG_BRANCH_NAME}" -git status - -# Delete and recreate tag locally. - -echo ">>>>>>>> git tag --delete \"${GITHUB_REF_NAME}\" -----------------------" -git tag --delete "${GITHUB_REF_NAME}" -git status - -echo ">>>>>>>> git tag \"${GITHUB_REF_NAME}\" --------------------------------" -git tag "${GITHUB_REF_NAME}" -git status - -# Delete and recreate tag remotely. - -#echo ">>>>>>>> git push origin \":${GITHUB_REF_NAME}\" ----------------------" -#git push origin ":${GITHUB_REF_NAME}" -#git status - -echo ">>>>>>>> git push origin \"${GITHUB_REF_NAME}\" ------------------------" -git push origin "${GITHUB_REF_NAME}" -git status - - -echo ">>>>>>>> gh release view -----------------------------------------------" -gh release view - -# Replace tag on GitHub. - -#echo ">>>>>>>> git push origin \":${GITHUB_REF}\" (to delete tag on origin)" -#git push origin ":${GITHUB_REF}" -#git status - -#echo ">>>>>>>> git tag --force --annotate \"${GITHUB_REF_NAME}\" --message \"Updated ${INPUT_FILENAME} for ${GITHUB_REF_NAME}.\"" -#git tag --force --annotate "${GITHUB_REF_NAME}" --message "Updated ${INPUT_FILENAME} for ${GITHUB_REF_NAME}." -#git status - -#echo ">>>>>>>> git push origin \"${GITHUB_REF}:${GITHUB_REF}\"" -#git push origin "HEAD:${GITHUB_REF}"# -#git status - - -echo ">>>>>>>> gh release create \"${RELEASE_VERSION}\" --latest --target \"${GITHUB_REF_NAME}\" --notes \"${RELEASE_BODY}\"" -gh release create \ - "${RELEASE_VERSION}" \ - --latest \ - --target "${GITHUB_REF_NAME}" \ - --notes "${RELEASE_BODY}" - -# git tag -a "v${GITHUB_REF_NAME}" -m "Go module tag for version ${GITHUB_REF_NAME} by ${GITHUB_ACTOR}" ${GITHUB_WORKFLOW_SHA} -# git push origin --tags - -echo ">>>>>>>> Done" - -exit 0 # Debug - -#------------------------------------------------------------------------------ -# Make a Pull Request for main branch. -#------------------------------------------------------------------------------ - -# Make a new branch. - -echo ">>>>>>>> git checkout -b \"${NEW_MAIN_BRANCH_NAME}\"" -git checkout -b "${NEW_MAIN_BRANCH_NAME}" -git status - -# Write the file into the branch. - -write_file - -# Inspect the file. - -echo "" -echo "Contents of ${OUTFILE}:" -echo "" -cat ${OUTFILE} - -# Commit the file to the branch and push branch to origin. - -echo ">>>>>>>> git add ${OUTFILE}" -git add ${OUTFILE} -git status - -echo ">>>>>>>> git commit -m \"make-go-version-file.yaml updated ${INPUT_FILENAME} for versioned release: ${RELEASE_VERSION}\"" -git commit -m "make-go-version-file.yaml updated ${INPUT_FILENAME} for versioned release: ${RELEASE_VERSION}" -git status - -echo ">>>>>>>> git push --set-upstream origin \"${NEW_MAIN_BRANCH_NAME}\"" -git push --set-upstream origin "${NEW_MAIN_BRANCH_NAME}" -git status - -# Create a Pull Request for the branch. - -echo ">>>>>>>> gh pr create --head \"${NEW_MAIN_BRANCH_NAME}\" --title \"make-go-version-file.yaml updated ${INPUT_FILENAME} for versioned release: ${RELEASE_VERSION}\" --body \"make-go-version-file.yaml updated ${INPUT_FILENAME} for versioned release: ${RELEASE_VERSION}\"" -gh pr create \ - --head "${NEW_MAIN_BRANCH_NAME}" \ - --title "make-go-version-file.yaml: ${INPUT_FILENAME}@${RELEASE_VERSION}" \ - --body "make-go-version-file.yaml updated ${INPUT_FILENAME} for versioned release: ${RELEASE_VERSION}" - -echo ">>>>>>>> Done" - diff --git a/docs/errors.md b/docs/errors.md index 05c6801..165d08c 100644 --- a/docs/errors.md +++ b/docs/errors.md @@ -1 +1 @@ -## Errors \ No newline at end of file +# Errors diff --git a/entrypoint.sh b/entrypoint.sh index 0313ea3..49a14d7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,24 +1,28 @@ -#!/bin/sh +#!/usr/bin/env bash +# shellcheck disable=SC2028 + set -eu # Function: write_file() write_file() { - echo "${FIRST_LINE}" > ${OUTFILE} - echo "// Created by make-go-github-file.yaml on $(date)" >> ${OUTFILE} - echo "//" >> ${OUTFILE} - echo "//lint:file-ignore U1000 Ignore all unused code, it's generated" >> ${OUTFILE} - echo "package ${INPUT_PACKAGE}" >> ${OUTFILE} - echo "" >> ${OUTFILE} - echo "var (" >> ${OUTFILE} - echo "\tgithubDate string = \"${RELEASE_DATE}\"" >> ${OUTFILE} - echo "\tgithubIteration string = \"${RELEASE_ITERATION}\"" >> ${OUTFILE} - echo "\tgithubRef string = \"refs/tags/${NEXT_VERSION}\"" >> ${OUTFILE} - echo "\tgithubRefName string = \"${NEXT_VERSION}\"" >> ${OUTFILE} - echo "\tgithubRepository string = \"${GITHUB_REPOSITORY}\"" >> ${OUTFILE} - echo "\tgithubRepositoryName string = \"${RELEASE_REPOSITORY_NAME}\"" >> ${OUTFILE} - echo "\tgithubVersion string = \"${NEXT_VERSION}\"" >> ${OUTFILE} - echo ")" >> ${OUTFILE} + { + echo "${FIRST_LINE}" + echo "// Created by make-go-github-file.yaml on $(date)" + echo "//" + echo "//lint:file-ignore U1000 Ignore all unused code, it's generated" + echo "package ${INPUT_PACKAGE}" + echo "" + echo "var (" + echo "\tgithubDate string = \"${RELEASE_DATE}\"" + echo "\tgithubIteration string = \"${RELEASE_ITERATION}\"" + echo "\tgithubRef string = \"refs/tags/${NEXT_VERSION}\"" + echo "\tgithubRefName string = \"${NEXT_VERSION}\"" + echo "\tgithubRepository string = \"${GITHUB_REPOSITORY}\"" + echo "\tgithubRepositoryName string = \"${RELEASE_REPOSITORY_NAME}\"" + echo "\tgithubVersion string = \"${NEXT_VERSION}\"" + echo ")" + } >> "${OUTFILE}" } #------------------------------------------------------------------------------ @@ -31,7 +35,7 @@ INPUT_FILENAME=$1 INPUT_PACKAGE=$2 INPUT_ACTOR="${3:-$GITHUB_ACTOR}" -echo " Input parameters: $@" +echo " Input parameters: $*" echo "Requested filename: ${INPUT_FILENAME}" echo "Requested package: ${INPUT_PACKAGE}" echo "Requested actor: ${INPUT_ACTOR}" @@ -51,7 +55,7 @@ cd "${GITHUB_WORKSPACE}" || exit # Synthesize variables. -RELEASE_REPOSITORY_NAME=$(basename ${GITHUB_REPOSITORY}) +RELEASE_REPOSITORY_NAME=$(basename "${GITHUB_REPOSITORY}") RELEASE_ITERATION="0" RELEASE_DATE=$(date +%Y-%m-%d) OUTFILE="${GITHUB_WORKSPACE}/${INPUT_FILENAME}" @@ -64,7 +68,7 @@ VERSION_MAJOR="${VERSION%%\.*}" VERSION_MINOR="${VERSION#*.}" VERSION_MINOR="${VERSION_MINOR%.*}" VERSION_PATCH="${VERSION##*.}" -NEXT_VERSION_PATCH=$((1+${VERSION_PATCH})) +NEXT_VERSION_PATCH=$((1+VERSION_PATCH)) echo "Version: ${VERSION}" echo "Version [major]: ${VERSION_MAJOR}" @@ -79,8 +83,8 @@ NEXT_BRANCH_NAME="make-go-github-file.yaml/${NEXT_VERSION}" FIRST_LINE="// ${NEXT_VERSION}" -if [ -f ${OUTFILE} ]; then - EXISTING_FIRST_LINE=$(head -n 1 ${OUTFILE}) +if [ -f "${OUTFILE}" ]; then + EXISTING_FIRST_LINE=$(head -n 1 "${OUTFILE}") if [ "${FIRST_LINE}" = "${EXISTING_FIRST_LINE}" ]; then echo "${OUTFILE} is up to date. No changes needed." exit 0 @@ -106,7 +110,7 @@ write_file echo "" echo "Contents of ${OUTFILE}:" echo "" -cat ${OUTFILE} +cat "${OUTFILE}" # DEBUG - If debugging, uncomment following line. Technique described in # https://github.com/Senzing/github-action-make-go-github-file/issues/65 @@ -115,7 +119,7 @@ cat ${OUTFILE} # Commit the file to the branch and push branch to origin. echo ">>>>>>>> git add ${OUTFILE}" -git add ${OUTFILE} +git add "${OUTFILE}" git status echo ">>>>>>>> git commit -m \"make-go-github-file.yaml updated ${INPUT_FILENAME} for versioned release: ${NEXT_VERSION}\""