From 5c44c452e3fc2c0e9100d724a71d664c6bff0ad6 Mon Sep 17 00:00:00 2001 From: utakeru Date: Thu, 8 Apr 2021 21:55:48 +0900 Subject: [PATCH 1/5] =?UTF-8?q?zip=E3=81=97=E3=81=A6tag=E3=82=92=E6=89=93?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=BF=E3=82=8B=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/blank.yml | 8 +++----- package.json | 20 ++++++++++++++++++++ zipTarget.txt | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 package.json create mode 100644 zipTarget.txt diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 95b8133..05a3885 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -8,7 +8,7 @@ on: push: branches: [ main ] pull_request: - branches: [ main ] + branches: [ main, zip-and-release ] # Allows you to run this workflow manually from the Actions tab # workflow_dispatch: @@ -25,15 +25,13 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - # Runs a single command using the runners shell - - name: Run a one-line script - run: echo Hello, world! - # Runs a set of commands using the runners shell - name: Run a multi-line script run: | echo Add other actions to build, echo test, and deploy your project + - name: Pack + run: npm run pack - name: Tag run: | git tag -a v0.0.1 -m "version 0.0.1" diff --git a/package.json b/package.json new file mode 100644 index 0000000..5d86204 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "github_actions_training", + "version": "1.0.0", + "description": "![CI](https://github.com/utakeru/github_actions_training/workflows/CI/badge.svg)", + "main": "index.js", + "scripts": { + "pack": "zip output_$npm_package_version.zip zipTarget.txt", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/utakeru/github_actions_training.git" + }, + "author": "utakeru", + "license": "MIT", + "bugs": { + "url": "https://github.com/utakeru/github_actions_training/issues" + }, + "homepage": "https://github.com/utakeru/github_actions_training#readme" +} diff --git a/zipTarget.txt b/zipTarget.txt new file mode 100644 index 0000000..d0513b2 --- /dev/null +++ b/zipTarget.txt @@ -0,0 +1 @@ +zip From 5d936e22b055b0dd1ba5f2ee0fddb56465249b9e Mon Sep 17 00:00:00 2001 From: utakeru Date: Thu, 8 Apr 2021 22:05:09 +0900 Subject: [PATCH 2/5] =?UTF-8?q?secret=E3=82=92=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/blank.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 05a3885..bdca393 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -33,6 +33,8 @@ jobs: - name: Pack run: npm run pack - name: Tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}}} run: | git tag -a v0.0.1 -m "version 0.0.1" git push origin --tags From 27ee62982a7b254aa98e6553ec043fb185838ee5 Mon Sep 17 00:00:00 2001 From: utakeru Date: Fri, 9 Apr 2021 00:01:21 +0900 Subject: [PATCH 3/5] tag release --- .github/workflows/blank.yml | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index bdca393..2dc24ea 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -2,13 +2,14 @@ name: CI -# Controls when the action will run. +# Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the main branch push: - branches: [ main ] + tags: + - "v*" pull_request: - branches: [ main, zip-and-release ] + branches: [main, zip-and-release] # Allows you to run this workflow manually from the Actions tab # workflow_dispatch: @@ -32,9 +33,29 @@ jobs: echo test, and deploy your project - name: Pack run: npm run pack - - name: Tag - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}}} + + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} + + - name: Get commit summary + id: get_commit_summary run: | - git tag -a v0.0.1 -m "version 0.0.1" - git push origin --tags + PREVIOUS_TAG=$(git tag --sort=-creatordate | sed -n 2p) + echo "PREVIOUS_TAG: $PREVIOUS_TAG" + COMMIT_SUMMARY="$(git log --oneline --pretty=tformat:"%h %s" $PREVIOUS_TAG..${{ github.ref }})" + COMMIT_SUMMARY="${COMMIT_SUMMARY//$'\n'/'%0A'}" + echo ::set-output name=COMMIT_SUMMARY::$COMMIT_SUMMARY + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.get_version.outputs.VERSION }} + release_name: Release ${{ steps.get_version.outputs.VERSION }} + body: | + ${{ steps.get_commit_summary.outputs.COMMIT_SUMMARY }} + draft: false + prerelease: false From 84b517b133b3a08b3a351988a702b43363567c5b Mon Sep 17 00:00:00 2001 From: utakeru Date: Fri, 9 Apr 2021 00:58:37 +0900 Subject: [PATCH 4/5] test --- .github/workflows/blank.yml | 15 ++++++++++++++- package.json | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 2dc24ea..3475169 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -32,7 +32,9 @@ jobs: echo Add other actions to build, echo test, and deploy your project - name: Pack - run: npm run pack + id: pack + run: | + echo ::set-output name=ZIP_FILE_NAME::$(npm run pack | awk '{if( $1 ~ "output_" ) print $1}') - name: Get the version id: get_version @@ -59,3 +61,14 @@ jobs: ${{ steps.get_commit_summary.outputs.COMMIT_SUMMARY }} draft: false prerelease: false + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./output_${{ steps.pack.outputs.ZIP_FILE_NAME }} + asset_name: meu.zip + asset_content_type: application/zip diff --git a/package.json b/package.json index 5d86204..e2d724d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "![CI](https://github.com/utakeru/github_actions_training/workflows/CI/badge.svg)", "main": "index.js", "scripts": { - "pack": "zip output_$npm_package_version.zip zipTarget.txt", + "pack": "FILENAME=output_$npm_package_version.zip && zip $FILENAME zipTarget.txt && echo $FILENAME", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { From 15bfce20ea007c56712861ccf2aec4c7acaca9a6 Mon Sep 17 00:00:00 2001 From: utakeru Date: Fri, 9 Apr 2021 00:58:37 +0900 Subject: [PATCH 5/5] test --- .github/workflows/blank.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 3475169..e15c224 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -69,6 +69,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./output_${{ steps.pack.outputs.ZIP_FILE_NAME }} - asset_name: meu.zip + asset_path: ./${{ steps.pack.outputs.ZIP_FILE_NAME }} + asset_name: ${{ steps.pack.outputs.ZIP_FILE_NAME }} asset_content_type: application/zip