Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 44 additions & 10 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
branches: [main, zip-and-release]

# Allows you to run this workflow manually from the Actions tab
# workflow_dispatch:
Expand All @@ -25,16 +26,49 @@ 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: Tag
- name: 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
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

- name: Upload Release Asset
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ steps.pack.outputs.ZIP_FILE_NAME }}
asset_name: ${{ steps.pack.outputs.ZIP_FILE_NAME }}
asset_content_type: application/zip
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": "FILENAME=output_$npm_package_version.zip && zip $FILENAME zipTarget.txt && echo $FILENAME",
"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"
}
1 change: 1 addition & 0 deletions zipTarget.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zip