From bd2d58b754d5f34265a7f7e4ad6e87d3a53e9143 Mon Sep 17 00:00:00 2001 From: herman Date: Wed, 6 Dec 2023 12:49:35 +0800 Subject: [PATCH 01/13] ADD: compress and release workflow --- .github/workflows/compressandrelease.yaml | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/compressandrelease.yaml diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml new file mode 100644 index 0000000..e14485d --- /dev/null +++ b/.github/workflows/compressandrelease.yaml @@ -0,0 +1,47 @@ +name: Compress Projects and Release + +on: + push: + branches: + - main # Trigger this workflow on push to main branch + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install zip + run: sudo apt-get install zip + + - name: Compress directories + run: | + for dir in */; do + base=$(basename "$dir") + zip -r "${base}.zip" "$dir" + echo "${base}.zip" >> zipfiles.txt + done + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload Release Asset + run: | + while IFS= read -r zipfile + do + echo "Uploading $zipfile" + curl \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: $(file -b --mime-type $zipfile)" \ + --data-binary @$zipfile \ + "${{ steps.create_release.outputs.upload_url }}?name=$(basename $zipfile)" + done < zipfiles.txt \ No newline at end of file From 25c154a074d6d51591bafa336ffe93208d9b5ea2 Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:13:49 +0800 Subject: [PATCH 02/13] MOD: update workflow --- .github/workflows/compressandrelease.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index e14485d..5a42226 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -1,9 +1,9 @@ name: Compress Projects and Release on: - push: - branches: - - main # Trigger this workflow on push to main branch + create: + tags: + - '*' jobs: release: @@ -29,7 +29,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token with: - tag_name: ${{ github.ref }} + tag_name: ${{ github.ref }} # This will be refs/heads/main for the main branch release_name: Release ${{ github.ref }} draft: false prerelease: false From 84fb99fedc2908156c171d2757bdfe762f1a170c Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:14:43 +0800 Subject: [PATCH 03/13] MOD: update workflow --- .github/workflows/compressandrelease.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index 5a42226..5fdcc16 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -1,9 +1,9 @@ name: Compress Projects and Release on: - create: - tags: - - '*' + push: + branches: + - main # Trigger this workflow on push to main branch jobs: release: From 07d28ae6196b99bbcff960e6fe8417700bd59ec7 Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:21:03 +0800 Subject: [PATCH 04/13] FIX: use latest tag --- .github/workflows/compressandrelease.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index 5fdcc16..5f11607 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -1,9 +1,9 @@ name: Compress Projects and Release on: - push: - branches: - - main # Trigger this workflow on push to main branch + create: + tags: + - '*' jobs: release: @@ -23,13 +23,17 @@ jobs: echo "${base}.zip" >> zipfiles.txt done + - name: Get latest tag + id: latest_tag + run: echo ::set-output name=tag::$(git describe --tags --abbrev=0) + - name: Create Release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token with: - tag_name: ${{ github.ref }} # This will be refs/heads/main for the main branch + tag_name: ${{ steps.latest_tag.outputs.tag }} release_name: Release ${{ github.ref }} draft: false prerelease: false From b78b48dca7cd84e92aa0eeca90556e08a8b2f6a7 Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:24:52 +0800 Subject: [PATCH 05/13] FIX: workflow --- .github/workflows/compressandrelease.yaml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index 5f11607..997ed76 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -38,14 +38,16 @@ jobs: draft: false prerelease: false - - name: Upload Release Asset + - name: Upload Release Assets + id: upload-release-assets run: | - while IFS= read -r zipfile + while IFS= read -r asset_path do - echo "Uploading $zipfile" + asset_name=$(basename $asset_path) + echo "Uploading $asset_path as $asset_name" curl \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -H "Content-Type: $(file -b --mime-type $zipfile)" \ - --data-binary @$zipfile \ - "${{ steps.create_release.outputs.upload_url }}?name=$(basename $zipfile)" + --data-binary @"$asset_path" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: $(file -b --mime-type $asset_path)" \ + "${{ steps.create_release.outputs.upload_url }}?name=$asset_name" done < zipfiles.txt \ No newline at end of file From 46950b7c7c81434fb505b02ea311a201fd1722eb Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:26:12 +0800 Subject: [PATCH 06/13] MOD: support manual run --- .github/workflows/compressandrelease.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index 997ed76..1debe19 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -1,6 +1,7 @@ name: Compress Projects and Release on: + workflow_dispatch: create: tags: - '*' From 24f8ed6c2ec36ae739ce0f12f36bc0d2b8455f76 Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:31:41 +0800 Subject: [PATCH 07/13] FIX --- .github/workflows/compressandrelease.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index 1debe19..ce819b2 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -24,9 +24,16 @@ jobs: echo "${base}.zip" >> zipfiles.txt done - - name: Get latest tag - id: latest_tag - run: echo ::set-output name=tag::$(git describe --tags --abbrev=0) + # - name: Get latest tag + # id: gettag + # run: | + # TAG=$(git describe --tags --abbrev=0 2>/dev/null) + # if [ "$?" -ne 0 ]; then + # echo "No tags found" + # echo ::set-output name=tag:: + # else + # echo ::set-output name=tag::$TAG + # fi - name: Create Release id: create_release @@ -34,7 +41,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token with: - tag_name: ${{ steps.latest_tag.outputs.tag }} + tag_name: ${{ github.ref }} release_name: Release ${{ github.ref }} draft: false prerelease: false From 0ef204ecd6445adc72403302c95100dda38e61ba Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:37:28 +0800 Subject: [PATCH 08/13] FIX --- .github/workflows/compressandrelease.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index ce819b2..ab034ec 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -57,5 +57,5 @@ jobs: --data-binary @"$asset_path" \ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "Content-Type: $(file -b --mime-type $asset_path)" \ - "${{ steps.create_release.outputs.upload_url }}?name=$asset_name" + "${{ steps.create_release.outputs.upload_url }}=$asset_name" done < zipfiles.txt \ No newline at end of file From 63e999ca6a743c9980bb1d5fdc94d018c2edaeec Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:41:21 +0800 Subject: [PATCH 09/13] MOD: refine workflow --- .github/workflows/compressandrelease.yaml | 28 ++++------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index ab034ec..af6beda 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -35,27 +35,9 @@ jobs: # echo ::set-output name=tag::$TAG # fi - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + - name: Create Release and Upload Assets + uses: softprops/action-gh-release@v1 with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - - - name: Upload Release Assets - id: upload-release-assets - run: | - while IFS= read -r asset_path - do - asset_name=$(basename $asset_path) - echo "Uploading $asset_path as $asset_name" - curl \ - --data-binary @"$asset_path" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -H "Content-Type: $(file -b --mime-type $asset_path)" \ - "${{ steps.create_release.outputs.upload_url }}=$asset_name" - done < zipfiles.txt \ No newline at end of file + files: zipfiles.txt + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From a6ceef16f9aa4246a6f2bc8fcae4d42492f08c3e Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:43:52 +0800 Subject: [PATCH 10/13] FIX --- .github/workflows/compressandrelease.yaml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index af6beda..f829b3c 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -24,20 +24,15 @@ jobs: echo "${base}.zip" >> zipfiles.txt done - # - name: Get latest tag - # id: gettag - # run: | - # TAG=$(git describe --tags --abbrev=0 2>/dev/null) - # if [ "$?" -ne 0 ]; then - # echo "No tags found" - # echo ::set-output name=tag:: - # else - # echo ::set-output name=tag::$TAG - # fi - - name: Create Release and Upload Assets + run: | + files=$(cat zipfiles.txt) + echo "files: $files" + echo "FILES=$files" >> $GITHUB_ENV + + - name: Release uses: softprops/action-gh-release@v1 with: - files: zipfiles.txt + files: ${{ env.FILES }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From de20615ce1915e0aded703fc4d9ba74dac7a2207 Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:47:52 +0800 Subject: [PATCH 11/13] FIX --- .github/workflows/compressandrelease.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index f829b3c..e78d0ec 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -26,7 +26,7 @@ jobs: - name: Create Release and Upload Assets run: | - files=$(cat zipfiles.txt) + files=$(tr '\n' ' ' < zipfiles.txt) echo "files: $files" echo "FILES=$files" >> $GITHUB_ENV From e9199bfde71224a47bbe3170eab4fc5b6cb5102e Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 13:58:57 +0800 Subject: [PATCH 12/13] FIX --- .github/workflows/compressandrelease.yaml | 33 +++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index e78d0ec..16d05b1 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -24,15 +24,26 @@ jobs: echo "${base}.zip" >> zipfiles.txt done - - name: Create Release and Upload Assets - run: | - files=$(tr '\n' ' ' < zipfiles.txt) - echo "files: $files" - echo "FILES=$files" >> $GITHUB_ENV - - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: ${{ env.FILES }} + - name: Create Release + id: create_release + uses: actions/create-release@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} # This will be your-tag-name for a tag + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload Release Assets + run: | + upload_url="${{ steps.create_release.outputs.upload_url }}" + for asset_path in $(cat zipfiles.txt); do + asset_name=$(basename $asset_path) + echo "Uploading $asset_path as $asset_name" + curl \ + --data-binary @"$asset_path" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: $(file -b --mime-type $asset_path)" \ + "$upload_url?name=$asset_name" + done \ No newline at end of file From 202df98429f1aa56d86d97563ac7e00b680ef93c Mon Sep 17 00:00:00 2001 From: Herman Wen Date: Wed, 6 Dec 2023 14:00:48 +0800 Subject: [PATCH 13/13] FIX --- .github/workflows/compressandrelease.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/compressandrelease.yaml b/.github/workflows/compressandrelease.yaml index 16d05b1..e45b95a 100644 --- a/.github/workflows/compressandrelease.yaml +++ b/.github/workflows/compressandrelease.yaml @@ -38,6 +38,7 @@ jobs: - name: Upload Release Assets run: | upload_url="${{ steps.create_release.outputs.upload_url }}" + upload_url="${upload_url/\{?name,label\}/}" for asset_path in $(cat zipfiles.txt); do asset_name=$(basename $asset_path) echo "Uploading $asset_path as $asset_name"