From c4fa38a4c883e847f25820055796b226e50c9ff3 Mon Sep 17 00:00:00 2001 From: Sudip Roy Date: Wed, 24 May 2023 15:38:57 +0530 Subject: [PATCH 01/32] trigger build native on PR and push Signed-off-by: Sudip Roy --- .github/workflows/build-native.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 40839a9f..54c51865 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -2,6 +2,20 @@ name: Build Native on: workflow_dispatch: + push: + paths: + - 'src/main/resources/org/xerial/snappy/VERSION' + - 'Makefile' + - 'Makefile.common' + - '**/*.h' + - '**/*.cpp' + pull_request: + paths: + - 'src/main/resources/org/xerial/snappy/VERSION' + - 'Makefile' + - 'Makefile.common' + - '**/*.h' + - '**/*.cpp' jobs: build: From 46be2488b9c2ddb7e5255caa06084731d94e7d9c Mon Sep 17 00:00:00 2001 From: Sudip Roy <59234028+imsudiproy@users.noreply.github.com> Date: Wed, 24 May 2023 16:58:38 +0530 Subject: [PATCH 02/32] Add branch master --- .github/workflows/build-native.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 54c51865..e9100ee6 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -3,6 +3,8 @@ name: Build Native on: workflow_dispatch: push: + branches: + - master paths: - 'src/main/resources/org/xerial/snappy/VERSION' - 'Makefile' From 10d78d23e1d15c91a32a2312fc571e6442cb1322 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 09:15:33 -0700 Subject: [PATCH 03/32] Trigger native lib build only for PRs --- .github/workflows/build-native.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index e9100ee6..1f2909a4 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -2,15 +2,6 @@ name: Build Native on: workflow_dispatch: - push: - branches: - - master - paths: - - 'src/main/resources/org/xerial/snappy/VERSION' - - 'Makefile' - - 'Makefile.common' - - '**/*.h' - - '**/*.cpp' pull_request: paths: - 'src/main/resources/org/xerial/snappy/VERSION' From 15e739f1d505077941ec8d1bcef7171e4cfb5c09 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 09:16:47 -0700 Subject: [PATCH 04/32] Test native lib build trigger --- Makefile.common | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.common b/Makefile.common index 69bed023..8c060e35 100755 --- a/Makefile.common +++ b/Makefile.common @@ -50,6 +50,7 @@ endif # os=Default is meant to be generic unix/linux +# To support new CPU architecture, add a new target name here known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armv6 Linux-armv7 Linux-android-arm Linux-android-aarch64 Linux-aarch64 Linux-ppc Linux-ppc64 Linux-ppc64le Linux-s390 Linux-s390x Mac-x86 Mac-x86_64 Mac-aarch64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc AIX-ppc64 Linux-riscv Linux-riscv64 os_arch := $(OS_NAME)-$(OS_ARCH) IBM_JDK_7 := $(findstring IBM, $(shell $(JAVA) -version 2>&1 | grep IBM | grep "JRE 1.7")) From 8b6a09ad4e446dfabb7212bd70342426d8c7dd8f Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 09:48:14 -0700 Subject: [PATCH 05/32] Targetting the PR repo --- .github/workflows/build-native.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 1f2909a4..d8aec972 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -14,6 +14,9 @@ jobs: build: name: Build native libraries runs-on: ubuntu-latest + outputs: + ref: ${{ steps.output.outputs.ref }} + repo: ${{ steps.output.outputs.repo }} steps: - uses: actions/checkout@v3 - name: Build native libraries @@ -25,12 +28,31 @@ jobs: with: name: native-libs path: src/main/resources/org/xerial/snappy/native/ + # This will set the branch to use: + # - if workflow_dispatch, use the branch that was chosen when running the workflow + # - if it is a comment on a PR, and the trigger matches, use the PR branch + - name: Set job output + id: output + run: | + echo "::echo::on" + if [[ "${{ github.event_name == 'workflow_dispatch' }}" == 'true' ]] + then + echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT + echo "repo=${{ github.repository }}" >> $GITHUB_OUTPUT + else + echo "ref=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT + echo "repo=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_OUTPUT + fi + push: name: Push new native libraries to branch runs-on: ubuntu-latest needs: [build] steps: - uses: actions/checkout@v3 + with: + repository: ${{ needs.build.outputs.repo }} + ref: ${{ needs.build.outputs.ref }} - name: Download native libraries uses: actions/download-artifact@v3 with: From 323a4993fece0d4127673bbfb368994797aa6a68 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 09:50:52 -0700 Subject: [PATCH 06/32] Add comment to trigger native lib build --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 2d2ed082..adba9cad 100644 --- a/Makefile +++ b/Makefile @@ -203,6 +203,8 @@ freebsd64: # For ARM native-arm: linux-arm64 linux-android-arm linux-android-aarch64 linux-arm linux-armv6 linux-armv7 + +# TODO: CROSS_PREFIX can be replaced with ${CROSS_ROOT}/bin/${CROSS_TRIPLE}- in Makefile.common linux-arm: jni-header ./docker/dockcross-armv5 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/xcc/armv5-unknown-linux-gnueabi/bin//armv5-unknown-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm' From 88951fe15fa0eb66758c90f1936a60bd73c2517b Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 09:52:26 -0700 Subject: [PATCH 07/32] Fix syntax error --- .github/workflows/build-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index d8aec972..a012886f 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -39,7 +39,7 @@ jobs: then echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT echo "repo=${{ github.repository }}" >> $GITHUB_OUTPUT - else + else echo "ref=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT echo "repo=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_OUTPUT fi From 6f86fa25137545cc4b4d10f4d0feb6d128fc2686 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 10:13:40 -0700 Subject: [PATCH 08/32] Test with write permission --- .github/workflows/build-native.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index a012886f..ee1e8a3f 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -9,6 +9,7 @@ on: - 'Makefile.common' - '**/*.h' - '**/*.cpp' + - .github/workflows/build-native.yml jobs: build: @@ -20,7 +21,8 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build native libraries - run: make clean-native native-all + # run: make clean-native native-all + run: make clean-native native env: OCI_EXE: docker - name: Upload native libraries @@ -45,6 +47,9 @@ jobs: fi push: + permissions: + # write permission is required for pushing commits + pull-requests: write name: Push new native libraries to branch runs-on: ubuntu-latest needs: [build] From adaf2a0c31951ce0859ceafa703fbae0b98c5704 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 10:15:38 -0700 Subject: [PATCH 09/32] Test with contents: write --- .github/workflows/build-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index ee1e8a3f..6eb45f3c 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -49,7 +49,7 @@ jobs: push: permissions: # write permission is required for pushing commits - pull-requests: write + contents: write name: Push new native libraries to branch runs-on: ubuntu-latest needs: [build] From 7f1dc61a5163d77cd4490267fa7c540725c9a76c Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 10:20:03 -0700 Subject: [PATCH 10/32] Test --- .github/workflows/build-native.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 6eb45f3c..dcf17ba1 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -55,9 +55,9 @@ jobs: needs: [build] steps: - uses: actions/checkout@v3 - with: - repository: ${{ needs.build.outputs.repo }} - ref: ${{ needs.build.outputs.ref }} + #with: + # repository: ${{ needs.build.outputs.repo }} + # ref: ${{ needs.build.outputs.ref }} - name: Download native libraries uses: actions/download-artifact@v3 with: From 967d0b965e8311b9f80c3ed7e260ae3cfd198008 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 10:21:44 -0700 Subject: [PATCH 11/32] test --- .github/workflows/build-native.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index dcf17ba1..01909df7 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -55,9 +55,9 @@ jobs: needs: [build] steps: - uses: actions/checkout@v3 - #with: - # repository: ${{ needs.build.outputs.repo }} - # ref: ${{ needs.build.outputs.ref }} + with: + repository: ${{ needs.build.outputs.repo }} + ref: ${{ needs.build.outputs.ref }} - name: Download native libraries uses: actions/download-artifact@v3 with: @@ -65,6 +65,8 @@ jobs: path: src/main/resources/org/xerial/snappy/native/ - run: git status - name: Commit and push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: EndBug/add-and-commit@v9 with: message: 'Update native libraries' From db2c8de2d1964e0ed878c3680bbba52c998498cb Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 10:26:15 -0700 Subject: [PATCH 12/32] Use gh pr checkout --- .github/workflows/build-native.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 01909df7..1982611e 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -54,10 +54,14 @@ jobs: runs-on: ubuntu-latest needs: [build] steps: - - uses: actions/checkout@v3 - with: - repository: ${{ needs.build.outputs.repo }} - ref: ${{ needs.build.outputs.ref }} + - name: Checkout PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh pr checkout ${{ github.event.pull_request.number }} + #- uses: actions/checkout@v3 + # with: + # repository: ${{ needs.build.outputs.repo }} + # ref: ${{ needs.build.outputs.ref }} - name: Download native libraries uses: actions/download-artifact@v3 with: From cb4baf888e257c93b45bab227f95f7313f8c1dc5 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 10:27:53 -0700 Subject: [PATCH 13/32] fix --- .github/workflows/build-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 1982611e..46f5be15 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -57,7 +57,7 @@ jobs: - name: Checkout PR env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh pr checkout ${{ github.event.pull_request.number }} + run: gh pr checkout ${{ github.event.pull_request.number }} #- uses: actions/checkout@v3 # with: # repository: ${{ needs.build.outputs.repo }} From 08aa4fc6b34eebbf5f5eedb3233faef7eefc8360 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 10:29:57 -0700 Subject: [PATCH 14/32] Add checkout phase --- .github/workflows/build-native.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 46f5be15..23b06593 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -54,14 +54,14 @@ jobs: runs-on: ubuntu-latest needs: [build] steps: + - uses: actions/checkout@v3 + # with: + # repository: ${{ needs.build.outputs.repo }} + # ref: ${{ needs.build.outputs.ref }} - name: Checkout PR env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh pr checkout ${{ github.event.pull_request.number }} - #- uses: actions/checkout@v3 - # with: - # repository: ${{ needs.build.outputs.repo }} - # ref: ${{ needs.build.outputs.ref }} - name: Download native libraries uses: actions/download-artifact@v3 with: From c0b36ebc1e541251096c5f225e8bba43f2fd68be Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 10:34:53 -0700 Subject: [PATCH 15/32] test target repo: --- .github/workflows/build-native.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 23b06593..97873378 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -55,9 +55,9 @@ jobs: needs: [build] steps: - uses: actions/checkout@v3 - # with: - # repository: ${{ needs.build.outputs.repo }} - # ref: ${{ needs.build.outputs.ref }} + with: + repository: ${{ needs.build.outputs.repo }} + ref: ${{ needs.build.outputs.ref }} - name: Checkout PR env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 18b340c62cadabd625cd61d1e5defc1d6eff174f Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 10:42:21 -0700 Subject: [PATCH 16/32] Try bot user --- .github/workflows/build-native.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 97873378..34401a8b 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -55,9 +55,6 @@ jobs: needs: [build] steps: - uses: actions/checkout@v3 - with: - repository: ${{ needs.build.outputs.repo }} - ref: ${{ needs.build.outputs.ref }} - name: Checkout PR env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -71,7 +68,8 @@ jobs: - name: Commit and push env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: EndBug/add-and-commit@v9 - with: - message: 'Update native libraries' - default_author: github_actions + run: | + git config --global user.name "xerial-bot" + git config --global user.email "leo+bot@xerial.org" + git commit -am 'Update native libraries' + git push From 46d96369e630d6f878eef574094b66a8cf912ca8 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 10:57:43 -0700 Subject: [PATCH 17/32] clanup --- .github/workflows/build-native.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 34401a8b..c2ffaf73 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -30,9 +30,6 @@ jobs: with: name: native-libs path: src/main/resources/org/xerial/snappy/native/ - # This will set the branch to use: - # - if workflow_dispatch, use the branch that was chosen when running the workflow - # - if it is a comment on a PR, and the trigger matches, use the PR branch - name: Set job output id: output run: | @@ -69,7 +66,5 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - git config --global user.name "xerial-bot" - git config --global user.email "leo+bot@xerial.org" git commit -am 'Update native libraries' git push From e8048d32d2b0cc3e88b946e0930f3553736b7354 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 11:29:53 -0700 Subject: [PATCH 18/32] Use PAT --- .github/workflows/build-native.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index c2ffaf73..2c0ac169 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -54,7 +54,7 @@ jobs: - uses: actions/checkout@v3 - name: Checkout PR env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.BOT_USER_TOKEN }} run: gh pr checkout ${{ github.event.pull_request.number }} - name: Download native libraries uses: actions/download-artifact@v3 @@ -64,7 +64,9 @@ jobs: - run: git status - name: Commit and push env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.BOT_USER_TOKEN }} run: | + git config --global user.name "xerial-bot" + git config --global user.email "leo+bot@xerial.org" git commit -am 'Update native libraries' git push From 1cc9cad564619f6379f84cf77ed61f1c7a7d3554 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 11:32:14 -0700 Subject: [PATCH 19/32] Use different user --- .github/workflows/build-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 2c0ac169..ca13613b 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -54,7 +54,7 @@ jobs: - uses: actions/checkout@v3 - name: Checkout PR env: - GITHUB_TOKEN: ${{ secrets.BOT_USER_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh pr checkout ${{ github.event.pull_request.number }} - name: Download native libraries uses: actions/download-artifact@v3 From 836ceccf9f3d79f2cb933ff72781d753d8100f44 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 11:41:27 -0700 Subject: [PATCH 20/32] simplify --- .github/workflows/build-native.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index ca13613b..7df930f6 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -47,15 +47,12 @@ jobs: permissions: # write permission is required for pushing commits contents: write + pull-requests: write name: Push new native libraries to branch runs-on: ubuntu-latest needs: [build] steps: - uses: actions/checkout@v3 - - name: Checkout PR - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh pr checkout ${{ github.event.pull_request.number }} - name: Download native libraries uses: actions/download-artifact@v3 with: From de4595c4508f01ebbe1ae116b75862d5169e8b58 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 11:44:28 -0700 Subject: [PATCH 21/32] fix --- .github/workflows/build-native.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 7df930f6..fd452131 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -53,6 +53,10 @@ jobs: needs: [build] steps: - uses: actions/checkout@v3 + - name: Checkout PR + env: + GITHUB_TOKEN: ${{ secrets.BOT_USER_TOKEN }} + run: gh pr checkout ${{ github.event.pull_request.number }} - name: Download native libraries uses: actions/download-artifact@v3 with: From b6953743cbaa43f2331390afe1cbba2879a840ef Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 11:45:56 -0700 Subject: [PATCH 22/32] test --- .github/workflows/build-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index fd452131..a39f6516 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v3 - name: Checkout PR env: - GITHUB_TOKEN: ${{ secrets.BOT_USER_TOKEN }} + GH_TOKEN: ${{ github.token }} run: gh pr checkout ${{ github.event.pull_request.number }} - name: Download native libraries uses: actions/download-artifact@v3 From e4d60b00e0776f1aad60c2aa308455d2bf452705 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 12:28:51 -0700 Subject: [PATCH 23/32] Fix token --- .github/workflows/build-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index a39f6516..fd452131 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v3 - name: Checkout PR env: - GH_TOKEN: ${{ github.token }} + GITHUB_TOKEN: ${{ secrets.BOT_USER_TOKEN }} run: gh pr checkout ${{ github.event.pull_request.number }} - name: Download native libraries uses: actions/download-artifact@v3 From aa1d7c7816447768eea49487e434f754176f1454 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 12:30:23 -0700 Subject: [PATCH 24/32] revert --- .github/workflows/build-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index fd452131..62f1238a 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v3 - name: Checkout PR env: - GITHUB_TOKEN: ${{ secrets.BOT_USER_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh pr checkout ${{ github.event.pull_request.number }} - name: Download native libraries uses: actions/download-artifact@v3 From 179f7ae5d4d27856b32f6de92223e9bc33d05474 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 12:33:05 -0700 Subject: [PATCH 25/32] Try push action --- .github/workflows/build-native.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 62f1238a..fe73ee5a 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -63,11 +63,12 @@ jobs: name: native-libs path: src/main/resources/org/xerial/snappy/native/ - run: git status - - name: Commit and push - env: - GITHUB_TOKEN: ${{ secrets.BOT_USER_TOKEN }} + - name: Commit run: | git config --global user.name "xerial-bot" git config --global user.email "leo+bot@xerial.org" git commit -am 'Update native libraries' - git push + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.BOT_USER_TOKEN }} From 3f1749905c96391f148fee4ca9763d71a5a1662f Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 12:37:29 -0700 Subject: [PATCH 26/32] use the same token --- .github/workflows/build-native.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index fe73ee5a..00f88485 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -53,17 +53,16 @@ jobs: needs: [build] steps: - uses: actions/checkout@v3 - - name: Checkout PR - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh pr checkout ${{ github.event.pull_request.number }} + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + token: ${{ secrets.BOT_USER_TOKEN }} - name: Download native libraries uses: actions/download-artifact@v3 with: name: native-libs path: src/main/resources/org/xerial/snappy/native/ - - run: git status - - name: Commit + - name: Commit files run: | git config --global user.name "xerial-bot" git config --global user.email "leo+bot@xerial.org" From 70e3565c7b1fb270cfb720f67e8c4c5d3860000f Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 12:37:56 -0700 Subject: [PATCH 27/32] fix tab --- .github/workflows/build-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 00f88485..33cac4ee 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} - fetch-depth: 0 + fetch-depth: 0 token: ${{ secrets.BOT_USER_TOKEN }} - name: Download native libraries uses: actions/download-artifact@v3 From b174905d76c97e80ffd00a647981c1dcc2b4cbf2 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 12:43:35 -0700 Subject: [PATCH 28/32] Set ref --- .github/workflows/build-native.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 33cac4ee..1853e88f 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -53,9 +53,9 @@ jobs: needs: [build] steps: - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - fetch-depth: 0 + with: + repository: ${{ needs.build.outputs.repo }} + ref: ${{ needs.build.outputs.ref }} token: ${{ secrets.BOT_USER_TOKEN }} - name: Download native libraries uses: actions/download-artifact@v3 From 5ec1d94fa166faff3dd4bee110819f2591642f27 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 13:01:50 -0700 Subject: [PATCH 29/32] Create a new PR for every master update --- .github/workflows/build-native.yml | 66 ++++++++++-------------------- 1 file changed, 21 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 1853e88f..18d7b339 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -2,7 +2,10 @@ name: Build Native on: workflow_dispatch: - pull_request: + push: + branches: + - master + - main paths: - 'src/main/resources/org/xerial/snappy/VERSION' - 'Makefile' @@ -10,14 +13,21 @@ on: - '**/*.h' - '**/*.cpp' - .github/workflows/build-native.yml + pull_request: + paths: + - 'src/main/resources/org/xerial/snappy/VERSION' + - 'Makefile' + - 'Makefile.common' + - '**/*.h' + - '**/*.cpp' jobs: build: + permissions: + contents: write + pull-requests: write name: Build native libraries runs-on: ubuntu-latest - outputs: - ref: ${{ steps.output.outputs.ref }} - repo: ${{ steps.output.outputs.repo }} steps: - uses: actions/checkout@v3 - name: Build native libraries @@ -25,49 +35,15 @@ jobs: run: make clean-native native env: OCI_EXE: docker - - name: Upload native libraries - uses: actions/upload-artifact@v3 - with: - name: native-libs - path: src/main/resources/org/xerial/snappy/native/ - - name: Set job output - id: output - run: | - echo "::echo::on" - if [[ "${{ github.event_name == 'workflow_dispatch' }}" == 'true' ]] - then - echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "repo=${{ github.repository }}" >> $GITHUB_OUTPUT else echo "ref=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT echo "repo=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_OUTPUT fi - - push: - permissions: - # write permission is required for pushing commits - contents: write - pull-requests: write - name: Push new native libraries to branch - runs-on: ubuntu-latest - needs: [build] - steps: - - uses: actions/checkout@v3 - with: - repository: ${{ needs.build.outputs.repo }} - ref: ${{ needs.build.outputs.ref }} - token: ${{ secrets.BOT_USER_TOKEN }} - - name: Download native libraries - uses: actions/download-artifact@v3 - with: - name: native-libs - path: src/main/resources/org/xerial/snappy/native/ - - name: Commit files - run: | - git config --global user.name "xerial-bot" - git config --global user.email "leo+bot@xerial.org" - git commit -am 'Update native libraries' - - name: Push changes - uses: ad-m/github-push-action@master + - name: Create Pull Request + if: ${{ github.event_name != 'pull_request' }} + uses: peter-evans/create-pull-request@v5 with: - github_token: ${{ secrets.BOT_USER_TOKEN }} + title: Update native libraries + commit-message: Updatge native libraries for ${{ github.sha }} + branch: update-native-libs + labels: library-update From c1592e28bf0b1ae2f9838595a7b23d2ed5a6d352 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 13:04:27 -0700 Subject: [PATCH 30/32] fix --- .github/workflows/build-native.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 18d7b339..7535808a 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -35,10 +35,6 @@ jobs: run: make clean-native native env: OCI_EXE: docker - else - echo "ref=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT - echo "repo=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_OUTPUT - fi - name: Create Pull Request if: ${{ github.event_name != 'pull_request' }} uses: peter-evans/create-pull-request@v5 From 1b4534e008b98676a098ad9ced8d239573ed4588 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 13:05:26 -0700 Subject: [PATCH 31/32] fix indent --- .github/workflows/build-native.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 7535808a..bbdf08f2 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -39,7 +39,7 @@ jobs: if: ${{ github.event_name != 'pull_request' }} uses: peter-evans/create-pull-request@v5 with: - title: Update native libraries - commit-message: Updatge native libraries for ${{ github.sha }} - branch: update-native-libs + title: Update native libraries + commit-message: Updatge native libraries for ${{ github.sha }} + branch: update-native-libs labels: library-update From 859432ed17c10f4ccdebf9b010a03ce8b91c07e1 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Wed, 24 May 2023 13:07:50 -0700 Subject: [PATCH 32/32] Use native-all --- .github/workflows/build-native.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index bbdf08f2..2e54e3ab 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -31,8 +31,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build native libraries - # run: make clean-native native-all - run: make clean-native native + run: make clean-native native-all env: OCI_EXE: docker - name: Create Pull Request