소스 검색

CI - bump copyright license year.
[ci skip]

Yao Wei Tjong 姚伟忠 4 년 전
부모
커밋
56df51ed68
3개의 변경된 파일103개의 추가작업 그리고 35개의 파일을 삭제
  1. 8 13
      .github/workflows/main.yml
  2. 49 0
      .github/workflows/nightly.yml
  3. 46 22
      rakefile

+ 8 - 13
.github/workflows/main.yml

@@ -23,7 +23,10 @@
 ---
 
 name: CI/CD
-on: [ push, pull_request ]
+on:
+  push:
+  pull_request:
+  repository_dispatch: { types: [ build ] }
 jobs:
   init:
     name: Init
@@ -103,36 +106,29 @@ jobs:
         run: rake update_dot_files && script/dockerized.sh ${PLATFORM/-*} env
       - name: CMake
         run: script/dockerized.sh ${PLATFORM/-*} rake cmake
-        if: matrix.platform != 'android' && matrix.platform != 'linux-clang-format'
+        if: matrix.platform != 'android'
       - name: Build
         run: script/dockerized.sh ${PLATFORM/-*} rake build
-        if: matrix.platform != 'linux-clang-format'
       - name: Test
         run: script/dockerized.sh ${PLATFORM/-*} rake test
         if: startsWith(matrix.platform, 'linux') || matrix.platform == 'android'
       - name: Documentation
         run: script/dockerized.sh ${PLATFORM/-*} rake doc
-        if: matrix.platform != 'linux-clang-tidy' && matrix.platform != 'linux-clang-format'
       - name: Scaffolding - install
         run: |
           script/dockerized.sh ${PLATFORM/-*} rake install
           if [[ $PLATFORM == android ]]; then touch build/cache/.gradle/mark; fi
-        if: matrix.platform != 'linux-clang-tidy' && matrix.platform != 'linux-clang-format'
       - name: Scaffolding - new
         run: script/dockerized.sh ${PLATFORM/-*} rake new
-        if: matrix.platform != 'linux-clang-tidy' && matrix.platform != 'linux-clang-format'
       - name: Scaffolding - build
         run: |
           cd build/cache/projects/UrhoApp
           script/dockerized.sh ${PLATFORM/-*}
-        if: matrix.platform != 'linux-clang-tidy' && matrix.platform != 'linux-clang-format'
       - name: Scaffolding - test
         run: |
           cd build/cache/projects/UrhoApp
           script/dockerized.sh ${PLATFORM/-*} rake test
-        if: |
-          matrix.platform == 'android' ||
-          (startsWith(matrix.platform, 'linux') && matrix.platform != 'linux-clang-tidy' && matrix.platform != 'linux-clang-format')
+        if: matrix.platform == 'android' || startsWith(matrix.platform, 'linux')
       - name: Scaffolding - cleanup
         run: |
           if [[ $PLATFORM == android ]]; then
@@ -141,10 +137,9 @@ jobs:
           else
             rm -rf build/cache/{.urho3d,projects}
           fi
-        if: matrix.platform != 'linux-clang-tidy' && matrix.platform != 'linux-clang-format'
       - name: Package
         run: script/dockerized.sh ${PLATFORM/-*} rake package
-        if: github.event_name == 'push' && matrix.platform != 'android' && matrix.platform != 'linux-clang-tidy' && matrix.platform != 'linux-clang-format'
+        if: github.event_name == 'push' && matrix.platform != 'android'
       - name: Upload
         uses: actions/upload-artifact@v2
         with:
@@ -155,7 +150,7 @@ jobs:
             android/urho3d-lib/build/distributions/*.zip
             android/urho3d-lib/build/libs/*.jar
             build/*.out
-        if: (success() && github.event_name == 'push') || (failure() && (matrix.platform == 'linux-clang-tidy' || matrix.platform == 'linux-clang-format'))
+        if: github.event_name == 'push'
         continue-on-error: ${{ !startsWith(github.ref, 'refs/tags/') }}
       - name: Publish
         env:

+ 49 - 0
.github/workflows/nightly.yml

@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2008-2021 the Urho3D 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
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# 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.
+#
+
+---
+
+name: Nightly
+on:
+  workflow_dispatch:
+  schedule: [cron: '0 0 * * *']
+jobs:
+  nightly:
+    name: Nightly build
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+      - name: Check license
+        id: check_license
+        run: rake check_license
+      - name: Dispatch
+        uses: peter-evans/[email protected]
+        with:
+          token: ${{ secrets.PUBLISHER_TOKEN }}
+          repository: urho3d/Urho3D
+          event-type: build
+        if: steps.check_license.outputs.dispatch == '1'
+
+...
+
+# vi: set ts=2 sw=2 expandtab:

+ 46 - 22
rakefile

@@ -171,6 +171,18 @@ end
 
 ### Internal tasks ###
 
+task :check_license do
+  # Automatically bump copyright when crossing a new year
+  if /2008-([0-9]{4}) the Urho3D project/.match(File.read('rakefile'))[1].to_i != Time.now.year
+    system %Q{
+      git config user.name #{ENV['PUBLISHER_NAME']} && \\
+      git config user.email #{ENV['PUBLISHER_EMAIL']} && \\
+      git add #{bump_copyright_year.join ' '} && \\
+      if git commit -qm 'GH Actions: Bump copyright to #{Time.now.year}.'; then git push; fi
+    } or abort "Failed to push copyright update"
+  end
+end
+
 task :ci do
   ENV['URHO3D_PCH'] = '0' if ENV['PLATFORM'] == 'linux-gcc' # TODO - PCH causes cache miss on initial build for Linux/GCC, why?
   platform_modifier = /(.+?)-(.+)/.match(ENV['PLATFORM'])
@@ -259,24 +271,8 @@ task :ci_publish_web do
   } or abort 'Failed to update Web samples'
 end
 
-task :source_checksum do
-  require 'digest'
-  sha256_final = Digest::SHA256.new
-  sha256_iter = Digest::SHA256
-  Dir['Source/**/*.{c,h}*'].each { |it| sha256_final << sha256_iter.file(it).hexdigest }
-  puts "::set-output name=hexdigest::#{sha256_final.hexdigest}"
-end
-
-task :update_dot_files do
-  system 'bash', '-c', %q{
-    perl -ne 'undef $/; print $1 if /(Build Option.*?(?=\n\n))/s' Docs/GettingStarted.dox \
-      |tail -n +3 |cut -d'|' -f2 |tr -d [:blank:] >script/.build-options && \
-    echo URHO3D_LINT >>script/.build-options && \
-    cat script/.build-options <(perl -ne 'while (/([A-Z_]+):.+?/g) {print "$1\n"}' .github/workflows/main.yml) \
-      <(perl -ne 'while (/ENV\[\x27(\w+)\x27\]/g) {print "$1\n"}' rakefile) \
-      <(perl -ne 'while (/System.getenv\\("(\w+)"\\)/g) {print "$1\n"}' android/urho3d-lib/build.gradle.kts) \
-      |sort |uniq |grep -Ev '^(HOME|PATH)$' >script/.env-file
-  } or abort 'Failed to update dot files'
+task :gradle, [:task] do |_, args|
+  system "#{ENV['OS'] ? 'gradlew.bat' : './gradlew'} #{args[:task]} #{ENV['CI'] ? '--console plain' : ''}" or abort
 end
 
 task :init do
@@ -315,10 +311,6 @@ task :init do
   ENV['URHO3D_64BIT'] = ENV['ARCH'] == '32' ? '0' : '1' if /32|64/ =~ ENV['ARCH']
 end
 
-task :gradle, [:task] do |_, args|
-  system "#{ENV['OS'] ? 'gradlew.bat' : './gradlew'} #{args[:task]} #{ENV['CI'] ? '--console plain' : ''}" or abort
-end
-
 task :lint do
   lint_err = File.read(lint_err_file)
   puts lint_err
@@ -339,6 +331,26 @@ task :style do
   puts 'Passed the style checks'
 end
 
+task :source_checksum do
+  require 'digest'
+  sha256_final = Digest::SHA256.new
+  sha256_iter = Digest::SHA256
+  Dir['Source/**/*.{c,h}*'].each { |it| sha256_final << sha256_iter.file(it).hexdigest }
+  puts "::set-output name=hexdigest::#{sha256_final.hexdigest}"
+end
+
+task :update_dot_files do
+  system 'bash', '-c', %q{
+    perl -ne 'undef $/; print $1 if /(Build Option.*?(?=\n\n))/s' Docs/GettingStarted.dox \
+      |tail -n +3 |cut -d'|' -f2 |tr -d [:blank:] >script/.build-options && \
+    echo URHO3D_LINT >>script/.build-options && \
+    cat script/.build-options <(perl -ne 'while (/([A-Z_]+):.+?/g) {print "$1\n"}' .github/workflows/main.yml) \
+      <(perl -ne 'while (/ENV\[\x27(\w+)\x27\]/g) {print "$1\n"}' rakefile) \
+      <(perl -ne 'while (/System.getenv\\("(\w+)"\\)/g) {print "$1\n"}' android/urho3d-lib/build.gradle.kts) \
+      |sort |uniq |grep -Ev '^(HOME|PATH)$' >script/.env-file
+  } or abort 'Failed to update dot files'
+end
+
 
 ### Internal methods ###
 
@@ -816,6 +828,18 @@ Thumbs.db
   EOF
 end
 
+def bump_copyright_year(regex = '2008-[0-9]{4} the Urho3D project')
+  begin
+    copyrighted = `git grep -El '#{regex}'`.split
+    copyrighted.each { |filename|
+      replaced_content = File.read(filename).gsub(/#{regex}/, regex.gsub('[0-9]{4}', Time.now.year.to_s))
+      File.open(filename, 'w') { |file| file.puts replaced_content }
+    }
+    return copyrighted
+  rescue
+    abort 'Failed to bump copyright year'
+  end
+end
 
 # Load custom rake scripts
 Dir['.rake/*.rake'].each { |r| load r }