diff --git a/.github/workflows/update-copyright.yml b/.github/workflows/update-copyright.yml new file mode 100644 index 0000000..eadb0d3 --- /dev/null +++ b/.github/workflows/update-copyright.yml @@ -0,0 +1,102 @@ +name: Update Copyright Year + +on: + # Allow manual execution from GitHub UI + workflow_dispatch: + # Automatically run on January 1st every year at 00:00 UTC + schedule: + - cron: "0 0 1 1 *" + +permissions: + contents: write # Required for creating branches and commits + pull-requests: write # Required for creating pull requests + +jobs: + update-copyright: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 # Fetch full history for proper git operations + + - name: Get current year + id: year + run: echo "current_year=$(date +%Y)" >> $GITHUB_OUTPUT + + - name: Check if LICENSE file exists + id: check_license + run: | + if [ -f LICENSE ]; then + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + echo "::warning::LICENSE file not found in repository" + fi + + - name: Update copyright year in LICENSE + if: steps.check_license.outputs.exists == 'true' + run: | + CURRENT_YEAR="${{ steps.year.outputs.current_year }}" + + # Update copyright year patterns: + # 1. "Copyright (c) 2023" -> "Copyright (c) 2023-YYYY" + # 2. "Copyright (c) 2023-XXXX" -> "Copyright (c) 2023-YYYY" + + # Check if already using range format + if grep -q "Copyright (c) 2023-" LICENSE; then + # Update existing range + sed -i "s/Copyright (c) 2023-[0-9]\{4\}/Copyright (c) 2023-$CURRENT_YEAR/" LICENSE + echo "Updated existing copyright range to 2023-$CURRENT_YEAR" + elif grep -q "Copyright (c) 2023 " LICENSE; then + # Convert single year to range + sed -i "s/Copyright (c) 2023 /Copyright (c) 2023-$CURRENT_YEAR /" LICENSE + echo "Converted copyright to range format: 2023-$CURRENT_YEAR" + else + echo "::notice::No copyright year pattern found that needs updating" + fi + + - name: Check for changes + id: check_changes + run: | + if git diff --quiet LICENSE; then + echo "has_changes=false" >> $GITHUB_OUTPUT + echo "::notice::LICENSE file is already up to date" + else + echo "has_changes=true" >> $GITHUB_OUTPUT + echo "Changes detected in LICENSE file" + fi + + - name: Display changes + if: steps.check_changes.outputs.has_changes == 'true' + run: | + echo "=== LICENSE file changes ===" + git diff LICENSE + + - name: Create Pull Request + if: steps.check_changes.outputs.has_changes == 'true' + uses: peter-evans/create-pull-request@v8 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: update copyright year to ${{ steps.year.outputs.current_year }}" + title: "chore: Update copyright year to ${{ steps.year.outputs.current_year }}" + body: | + ## Summary + This PR automatically updates the copyright year in the LICENSE file to ${{ steps.year.outputs.current_year }}. + + ## Changes + - Updated `LICENSE` file copyright notice from `2023` or `2023-XXXX` to `2023-${{ steps.year.outputs.current_year }}` + + ## Notes + - This PR was automatically created by the "Update Copyright Year" GitHub Actions workflow + - Please review and merge to keep the copyright year current + + --- + *Generated by `.github/workflows/update-copyright.yml`* + branch: auto-update-copyright-${{ steps.year.outputs.current_year }} + base: main + delete-branch: true + labels: | + automated + maintenance diff --git a/LICENSE.txt b/LICENSE similarity index 94% rename from LICENSE.txt rename to LICENSE index 6473d7f..4ee8238 100644 --- a/LICENSE.txt +++ b/LICENSE @@ -1,4 +1,6 @@ -Copyright (c) 2021 Masato Onodera +MIT License + +Copyright (c) 2023-2026 Subaru PFS Project Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -17,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/pyproject.toml b/pyproject.toml index 569e073..e1451b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,44 +1,40 @@ [project] # name = "targetdb" name = "ets_target_database" -# version = "0.1.0" -dynamic = ["version"] description = "PFS target database (targetDB) tools" -authors = [{ name = "Masato Onodera", email = "monodera@naoj.org" }] -dependencies = [ - "alembic", - "astropy", - "loguru", - "numpy>=2.0", - "openpyxl", - "pandas", - "psycopg2-binary", - "pyarrow", - # "setuptools", - "sqlalchemy-utils", - "sqlalchemy", - "tabulate", - # "wheel", - 'tomli >= 1.1.0 ; python_version < "3.11"', - "typer", -] -requires-python = ">=3.11, <3.13" readme = "README.md" -license = { text = "MIT" } +requires-python = ">=3.11, <3.13" +license = "MIT" +license-files = ["LICENSE"] +authors = [{ name = "Masato Onodera", email = "monodera@naoj.org" }] classifiers = [ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Database", - "Topic :: Scientific/Engineering :: Astronomy", + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Database", + "Topic :: Scientific/Engineering :: Astronomy", ] - -[project.optional-dependencies] -dev = ["ipython", "pytest", "black", "ruff"] -doc = ["mkdocs", "mkdocs-material[imaging]", "mkdocstrings-python"] +dependencies = [ + "alembic", + "astropy", + "loguru", + "numpy>=2.0", + "openpyxl", + "pandas", + "psycopg2-binary", + "pyarrow", + "sqlalchemy", + # "setuptools", + "sqlalchemy-utils", + "tabulate", + # "wheel", + 'tomli >= 1.1.0 ; python_version < "3.11"', + "typer", +] +# version = "0.1.0" +dynamic = ["version"] [project.urls] homepage = "https://github.com/Subaru-PFS/ets_target_database" @@ -47,17 +43,32 @@ source = "https://github.com/Subaru-PFS/ets_target_database" [project.scripts] pfs-targetdb-cli = "targetdb.cli.cli_main:app" +[project.optional-dependencies] +dev = ["ipython", "pytest", "black", "ruff"] +doc = ["mkdocs", "mkdocs-material[imaging]", "mkdocstrings-python"] [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" -[tool.setuptools] -package-dir = { "" = "src" } -include-package-data = true +[tool.black] +line-length = 88 -[tool.setuptools.dynamic] -version = { attr = "targetdb.__version__" } +[tool.pdm.scripts] +serve-doc = { shell = "mkdocs serve", help = "Start the dev server for doc preview" } +build-doc = { shell = "mkdocs build", help = "Build documentation" } +gen-requirements = { cmd = [ + "pdm", + "export", + "--format", + "requirements", + "--without-hashes", + "--pyproject", + "--dev", + "--output", + "requirements.txt", + "--verbose", +], help = "Generate requirements.txt" } [tool.ruff] target-version = "py312" @@ -66,11 +77,11 @@ line-length = 88 [tool.ruff.lint] ignore = [ - "F401", # module imported but unused - "F841", # local variable is assigned to but never used - "E501", # line too long, handled by black - "B008", # do not perform function calls in argument defaults - "C901", # too complex + "F401", # module imported but unused + "F841", # local variable is assigned to but never used + "E501", # line too long, handled by black + "B008", # do not perform function calls in argument defaults + "C901", # too complex ] # select = [ # "E", # pycodestyle errors @@ -82,21 +93,9 @@ ignore = [ # "UP", # pyupgrade # ] -[tool.black] -line-length = 88 +[tool.setuptools] +package-dir = { "" = "src" } +include-package-data = true -[tool.pdm.scripts] -serve-doc = { shell = "mkdocs serve", help = "Start the dev server for doc preview" } -build-doc = { shell = "mkdocs build", help = "Build documentation" } -gen-requirements = { cmd = [ - "pdm", - "export", - "--format", - "requirements", - "--without-hashes", - "--pyproject", - "--dev", - "--output", - "requirements.txt", - "--verbose", -], help = "Generate requirements.txt" } +[tool.setuptools.dynamic] +version = { attr = "targetdb.__version__" }