From b44ef97c893d0bf3d235d89752ddd30e4cc6edd6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 17 Oct 2024 11:15:55 +0900 Subject: [PATCH] CI: build packages --- .github/workflows/main.yml | 46 +++++++++++++++++++++++++++++++++++++- rakelib/epoch.rake | 5 +++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 rakelib/epoch.rake diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4786eb1..47236ba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,12 +19,20 @@ jobs: needs: ruby-versions name: CI (${{ matrix.ruby }} / ${{ matrix.os }}) runs-on: ${{ matrix.os }} + outputs: + chksum_ubuntu: ${{ steps.build.outputs.chksum_ubuntu }} + chksum_windows: ${{ steps.build.outputs.chksum_windows }} strategy: matrix: ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }} - os: [ ubuntu-latest, windows-latest ] + os: [ ubuntu-24.04, windows-latest ] steps: + - name: git config + run: | + git config --global core.autocrlf false + git config --global core.eol lf + git config --global advice.detachedHead 0 - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -33,3 +41,39 @@ jobs: bundler-cache: true - name: Run the default task run: bundle exec rake + + - id: build + run: | + bundle exec rake build + sum="`sha256sum -b pkg/*`" + echo "$sum" + echo "chksum_${BUILD_PLATFORM%%-*}=$sum" >> $GITHUB_OUTPUT + echo "pkg=${GITHUB_REPOSITORY#*/}" >> $GITHUB_OUTPUT + if: >- + ${{ + github.event_name == 'push' && + (matrix.ruby == needs.ruby-versions.outputs.latest) + }} + env: + BUILD_PLATFORM: ${{ matrix.os }} + shell: bash + - name: Upload package + uses: actions/upload-artifact@v4 + with: + path: pkg/*.gem + name: ${{steps.build.outputs.pkg}}-${{matrix.os}} + if: >- + steps.build.outputs.pkg && + startsWith(matrix.os, 'ubuntu') + + comp: + name: ${{ github.workflow }} result + runs-on: ubuntu-latest + needs: [build] + steps: + - run: test "$chksum_ubuntu" = "$chksum_windows" + working-directory: + shell: bash + env: + chksum_ubuntu: ${{ needs.build.outputs.chksum_ubuntu }} + chksum_windows: ${{ needs.build.outputs.chksum_windows }} diff --git a/rakelib/epoch.rake b/rakelib/epoch.rake new file mode 100644 index 0000000..80f27c9 --- /dev/null +++ b/rakelib/epoch.rake @@ -0,0 +1,5 @@ +task "build" => "date_epoch" + +task "date_epoch" do + ENV["SOURCE_DATE_EPOCH"] = IO.popen(%W[git -C #{__dir__} log -1 --format=%ct], &:read).chomp +end