From dc4af3f4861f6b8236a6d1f47f1c4b3c32ffdf05 Mon Sep 17 00:00:00 2001 From: John Judd Date: Wed, 19 Feb 2025 16:49:46 -0600 Subject: [PATCH] Add changlog releaser. Update changelog. Update docs. --- .github/workflows/codecov.yml | 3 -- .github/workflows/ensure_changelog.yml | 16 +++++++ .github/workflows/go.yml | 3 -- .github/workflows/golangci-lint.yml | 5 --- .github/workflows/release-by-changelog.yml | 52 ++++++++++++++++++++++ .github/workflows/scripts/changelog.sh | 36 +++++++++++++++ CHANGELOG.md | 9 ++++ License.md | 2 +- README.md | 21 +-------- backend/mem/file_test.go | 4 +- backend/s3/file.go | 2 +- 11 files changed, 119 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/ensure_changelog.yml create mode 100644 .github/workflows/release-by-changelog.yml create mode 100644 .github/workflows/scripts/changelog.sh diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index d90453f8..af42a5ab 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -4,9 +4,6 @@ on: push: branches: - main - pull_request: - branches: - - main jobs: test: diff --git a/.github/workflows/ensure_changelog.yml b/.github/workflows/ensure_changelog.yml new file mode 100644 index 00000000..c041eea8 --- /dev/null +++ b/.github/workflows/ensure_changelog.yml @@ -0,0 +1,16 @@ +name: CHANGELOG.md Check +on: + pull_request: + branches: + - main +jobs: + verify_changelog_job: + runs-on: ubuntu-latest + name: Did CHANGELOG.md change? + steps: + - name: checkout + uses: actions/checkout@v4 + - name: fetch + run: git fetch + - name: run changelog.sh + run: 'bash ${GITHUB_WORKSPACE}/.github/workflows/scripts/changelog.sh' \ No newline at end of file diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e7696d45..6f994d46 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,9 +1,6 @@ name: Go on: - push: - branches: - - main pull_request: branches: - main diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index a64690e0..5d764e47 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,10 +1,5 @@ name: golangci-lint on: - push: - tags: - - v* - branches: - - main pull_request: jobs: golangci: diff --git a/.github/workflows/release-by-changelog.yml b/.github/workflows/release-by-changelog.yml new file mode 100644 index 00000000..b52aac98 --- /dev/null +++ b/.github/workflows/release-by-changelog.yml @@ -0,0 +1,52 @@ +name: Release by Changelog + +on: + push: + branches: + - main + workflow_dispatch: + inputs: + branch: + description: 'Branch to create a release from' + required: true + default: 'main' + version: + description: 'Specify the semantic version for the release (vX.Y.Z)' + required: true + reason: + description: 'Reason for the manual release' + required: false + +jobs: + release: + runs-on: ubuntu-latest + + env: + GOPROXY: proxy.golang.org,direct + GOPRIVATE: github.com/c2fo,github.com/C2FO + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.branch || github.ref_name }} + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.24 + + - name: Install and run ReleaseGen + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_ACTOR: ${{ github.actor }} + GITHUB_REF_NAME: ${{ github.event.inputs.branch || github.ref_name }} + MANUAL_VERSION: ${{ github.event.inputs.version || '' }} + REASON: ${{ github.event.inputs.reason || '' }} + CUSTOM_CHANGE_TYPES: | + documentation:patch + run: | + git config --global url."https://c2fo-read-only:${{ secrets.GH_CI_READ }}@github.com/c2fo".insteadOf "https://github.com/c2fo" + go install github.com/c2fo/ep-tools/releasegen@latest + releasegen \ No newline at end of file diff --git a/.github/workflows/scripts/changelog.sh b/.github/workflows/scripts/changelog.sh new file mode 100644 index 00000000..69f011f1 --- /dev/null +++ b/.github/workflows/scripts/changelog.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Find all directories containing a CHANGELOG.md file +changelogDirs=$(find . -type f -name 'CHANGELOG.md' -exec dirname {} \;) + +# Check each directory for changes and ensure CHANGELOG.md is updated +for dir in $changelogDirs; do + echo "Checking directory: $dir" + + # Check if there are any changes in the directory + dirChanges=$(git --no-pager diff -w --numstat origin/main -- $dir | wc -l) + if [[ "$dirChanges" -gt 0 ]]; then + echo "Changes detected in $dir" + + # Check if CHANGELOG.md has been modified + changelogMod=$(git --no-pager diff -w --numstat origin/main -- $dir/CHANGELOG.md) + if [[ -z "$changelogMod" ]]; then + echo "CHANGELOG.md in $dir has not been modified. Please update it with your changes before merging to main." + exit 1 + else + echo "CHANGELOG.md in $dir has been modified. Verifying at least 1 (non-whitespace) line has been added." + changelogLines=$(echo "$changelogMod" | awk '{print $1}') + if [[ "$changelogLines" -lt 1 ]]; then + echo "Didn't detect any substantial changes to CHANGELOG.md in $dir." + exit 1 + else + echo "Detected '$changelogLines' new non-whitespace lines in CHANGELOG.md in $dir. Thanks +1" + fi + fi + else + echo "No changes detected in $dir" + fi +done + +echo "All directories with changes have updated CHANGELOG.md files." +exit 0 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 214079da..a47691f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + ### Added - Add support for role based authentication in s3 backend. +- Changelog-based release generation(releasegen). + +### Security +- Update dependencies +- Update go to 1.23 from 1.22 (1.24 is out now) + +### Documentation +- Update README.md with go version policy ## [6.25.1] - 2025-01-09 ### Fixed diff --git a/License.md b/License.md index e584b88e..ae326743 100644 --- a/License.md +++ b/License.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2019-2021 C2FO, Inc +Copyright (c) 2019-2025 C2FO, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 0a171dcc..bd04a036 100644 --- a/README.md +++ b/README.md @@ -166,25 +166,8 @@ Things to add: * Provide better List() functionality with more abstracted filtering and paging (iterator?) Return File structs vs URIs? * Add better/any context.Context() support -### Contributors - -Brought to you by the Enterprise Pipeline team at C2FO: - -* John Judd - john.judd@c2fo.com - -* Dustin Schnee - dustin.schnee@c2fo.com - -* Katie Hrenchir Shields - katie.shields@c2fo.com - -* Grant Higgins - grant.higgins@c2fo.com - -* Pooja Dhondge - pooja.dhondge@c2fo.com - -* Chris Roush – chris.roush@c2fo.com - -* Anthony Ross - anthony.ross@c2fo.com - -https://github.com/c2fo/ +### Supported Go Versions +This project supports the latest and previous major Go versions. Please ensure you are using one of these versions to avoid compatibility issues. ### Contributing diff --git a/backend/mem/file_test.go b/backend/mem/file_test.go index b9cfd1c5..f16e330e 100644 --- a/backend/mem/file_test.go +++ b/backend/mem/file_test.go @@ -381,7 +381,7 @@ func (s *memFileTest) TestCopyToLocationOS() { s.NoError(copiedFile.Close(), "unexpected Close error") s.NotNil(copiedFile) - s.Equal("/test_files/test.txt", s.testFile.Path()) // testFile's path should be unchanged + s.Equal("/test_files/test.txt", s.testFile.Path()) // testFile's path should be unchanged s.Equal(path.Join(osFile.Location().Path(), "test.txt"), copiedFile.Path()) // new path should be that _, err = copiedFile.Read(readSlice) @@ -391,7 +391,7 @@ func (s *memFileTest) TestCopyToLocationOS() { s.NoError(err, "unexpected read error") s.Equal(readSlice2, readSlice) // both reads should be the same s.Require().NoError(copiedFile.Close()) - cleanErr := os.RemoveAll(dir) // clean up + cleanErr := os.RemoveAll(dir) // clean up s.NoError(cleanErr, "unexpected error cleaning up osFiles") } diff --git a/backend/s3/file.go b/backend/s3/file.go index 4592aebb..e4788979 100644 --- a/backend/s3/file.go +++ b/backend/s3/file.go @@ -566,7 +566,7 @@ func (f *File) getHeadObject() (*s3.HeadObjectOutput, error) { } // For copy from S3-to-S3 when credentials are the same between source and target, return *s3.CopyObjectInput or error -func (f *File) getCopyObjectInput(targetFile *File) (*s3.CopyObjectInput, error) { +func (f *File) getCopyObjectInput(targetFile *File) (*s3.CopyObjectInput, error) { //nolint:gocyclo // first we must determine if we're using the same s3 credentials for source and target before doing a native copy isSameAccount := false var ACL string