From 54ca905bd9db17132b55e177a6431a348c85f636 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Sat, 28 Sep 2024 08:58:47 +0900 Subject: [PATCH 1/6] [CI]: create a release and attach artifacts to it --- .github/workflows/ci.yml | 4 ++- .github/workflows/create-release.yml | 18 ++++++++++++ .github/workflows/publish-artifacts.yml | 39 +++++++++++++++++++++++++ .github/workflows/windows-build.yml | 21 ++++++++++++- ReleaseNote.md | 1 + 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/create-release.yml create mode 100644 .github/workflows/publish-artifacts.yml create mode 100644 ReleaseNote.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28f3a4f..c4a7201 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,4 +37,6 @@ jobs: windows-build: needs: check-workflows - uses: ./.github/workflows/windows-build.yml \ No newline at end of file + uses: ./.github/workflows/windows-build.yml + with: + upload-artifacts: false diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..4c9135f --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,18 @@ +name: Create a Release + +on: + push: + tags: + - v*.*.* + +jobs: + create-release: + runs-on: windows-latest + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - name: Create a Release + run: gh release create ${{ github.ref }} -F ReleaseNote.md diff --git a/.github/workflows/publish-artifacts.yml b/.github/workflows/publish-artifacts.yml new file mode 100644 index 0000000..b0bd859 --- /dev/null +++ b/.github/workflows/publish-artifacts.yml @@ -0,0 +1,39 @@ +name: Publish artifacts to Release + +on: + release: + types: [published] + +jobs: + check-workflows: + uses: ./.github/workflows/check-workflows.yml + + build-artifacts: + needs: check-workflows + uses: ./.github/workflows/windows-build.yml + with: + upload-artifacts: true + + publish-artifacts: + needs: check-workflows + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Download ocesql.exe + uses: actions/download-artifact@v4 + with: + name: ocesql.exe + + - name: Download ocesql.exe + uses: actions/download-artifact@v4 + with: + name: ocesql4j.jar + + - name: Publish artifacts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ github.ref }} ocesql.exe --clobber + gh release upload ${{ github.ref }} ocesql4j.jar --clobber diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 39ad70a..7f6cb1c 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -2,6 +2,11 @@ name: Windows build on: workflow_call: + inputs: + upload-artifacts: + description: 'Upload artifacts' + required: true + type: boolean permissions: contents: read @@ -94,4 +99,18 @@ jobs: run: | fc /b .\sample-result ..\win\sample-correct > test-result findstr "no differences encountered" test-result - shell: cmd \ No newline at end of file + shell: cmd + + - name: Upload ocesql.exe + if: ${{ github.event.inputs.upload-artifacts }} + uses: actions/upload-artifact@v4 + with: + name: ocesql.exe + path: win\x64\Release\ocesql.exe + + - name: Upload ocesql.exe + if: ${{ github.event.inputs.upload-artifacts }} + uses: actions/upload-artifact@v4 + with: + name: ocesql4j.jar + path: dblibj\target\scala-2.13\ocesql4j.jar diff --git a/ReleaseNote.md b/ReleaseNote.md new file mode 100644 index 0000000..04b83ff --- /dev/null +++ b/ReleaseNote.md @@ -0,0 +1 @@ +This is a sample release \ No newline at end of file From f8d8c0e38785d831c691929ac76921f2013dd1ac Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Sat, 28 Sep 2024 09:36:12 +0900 Subject: [PATCH 2/6] [Fix]: delete publish-artifacts.yml --- .github/workflows/create-release.yml | 32 ++++++++++++++++++-- .github/workflows/publish-artifacts.yml | 39 ------------------------- 2 files changed, 30 insertions(+), 41 deletions(-) delete mode 100644 .github/workflows/publish-artifacts.yml diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 4c9135f..0637a87 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -6,13 +6,41 @@ on: - v*.*.* jobs: + check-workflows: + uses: ./.github/workflows/check-workflows.yml + + build-artifacts: + needs: check-workflows + uses: ./.github/workflows/windows-build.yml + with: + upload-artifacts: true + create-release: + needs: build-artifacts runs-on: windows-latest + permissions: + contents: read + packages: write env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4 - - name: Create a Release run: gh release create ${{ github.ref }} -F ReleaseNote.md + + - name: Download ocesql.exe + uses: actions/download-artifact@v4 + with: + name: ocesql.exe + + - name: Download ocesql.exe + uses: actions/download-artifact@v4 + with: + name: ocesql4j.jar + + - name: Publish artifacts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ github.ref }} ocesql.exe --clobber + gh release upload ${{ github.ref }} ocesql4j.jar --clobber diff --git a/.github/workflows/publish-artifacts.yml b/.github/workflows/publish-artifacts.yml deleted file mode 100644 index b0bd859..0000000 --- a/.github/workflows/publish-artifacts.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Publish artifacts to Release - -on: - release: - types: [published] - -jobs: - check-workflows: - uses: ./.github/workflows/check-workflows.yml - - build-artifacts: - needs: check-workflows - uses: ./.github/workflows/windows-build.yml - with: - upload-artifacts: true - - publish-artifacts: - needs: check-workflows - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Download ocesql.exe - uses: actions/download-artifact@v4 - with: - name: ocesql.exe - - - name: Download ocesql.exe - uses: actions/download-artifact@v4 - with: - name: ocesql4j.jar - - - name: Publish artifacts - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload ${{ github.ref }} ocesql.exe --clobber - gh release upload ${{ github.ref }} ocesql4j.jar --clobber From b2d4672116642a88fe56fae0fcc7a41d44e33c83 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Sat, 28 Sep 2024 09:45:59 +0900 Subject: [PATCH 3/6] [Fix]: fix .github/workflows/create-release.yml --- .github/workflows/create-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 0637a87..e8320f1 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -17,7 +17,7 @@ jobs: create-release: needs: build-artifacts - runs-on: windows-latest + runs-on: ubuntu-latest permissions: contents: read packages: write @@ -25,6 +25,8 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: + - uses: actions/checkout@v4 + - name: Create a Release run: gh release create ${{ github.ref }} -F ReleaseNote.md From 6c159844794bc2ca81e96629e6007ad8ba3d5f2e Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Sat, 28 Sep 2024 10:00:14 +0900 Subject: [PATCH 4/6] [Fix]: change permissions specified in create-release.yml --- .github/workflows/create-release.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index e8320f1..e46d61b 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -19,8 +19,7 @@ jobs: needs: build-artifacts runs-on: ubuntu-latest permissions: - contents: read - packages: write + contents: write env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -41,8 +40,6 @@ jobs: name: ocesql4j.jar - name: Publish artifacts - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release upload ${{ github.ref }} ocesql.exe --clobber gh release upload ${{ github.ref }} ocesql4j.jar --clobber From b4ff0cf44424fb93af1ff7a8ade89e363742994a Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Sat, 28 Sep 2024 10:12:12 +0900 Subject: [PATCH 5/6] [Fix]: if condition expressions in windiws-build.yml --- .github/workflows/create-release.yml | 2 +- .github/workflows/windows-build.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index e46d61b..7f59686 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -34,7 +34,7 @@ jobs: with: name: ocesql.exe - - name: Download ocesql.exe + - name: Download ocesql4j.jar uses: actions/download-artifact@v4 with: name: ocesql4j.jar diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 7f6cb1c..55b09cf 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -102,14 +102,14 @@ jobs: shell: cmd - name: Upload ocesql.exe - if: ${{ github.event.inputs.upload-artifacts }} + if: ${{ inputs.upload-artifacts }} uses: actions/upload-artifact@v4 with: name: ocesql.exe path: win\x64\Release\ocesql.exe - name: Upload ocesql.exe - if: ${{ github.event.inputs.upload-artifacts }} + if: ${{ inputs.upload-artifacts }} uses: actions/upload-artifact@v4 with: name: ocesql4j.jar From 3b3007980fbff115e93f31f87a995bcfbea24fc9 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Sat, 28 Sep 2024 10:21:20 +0900 Subject: [PATCH 6/6] [Fix]: fix create-release.yml --- .github/workflows/create-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 7f59686..ca69bde 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -41,5 +41,5 @@ jobs: - name: Publish artifacts run: | - gh release upload ${{ github.ref }} ocesql.exe --clobber - gh release upload ${{ github.ref }} ocesql4j.jar --clobber + gh release upload ${{ github.ref_name }} ocesql.exe --clobber + gh release upload ${{ github.ref_name }} ocesql4j.jar --clobber