Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: auto-update script detection and workflow release #24

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
51 changes: 51 additions & 0 deletions .github/workflows/tag-release-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Create new `git tag`, create new GitHub release and publish to NPM

on:
push:
branches:
- "master"

jobs:
create_git_tag:
name: Create new `git tag`
runs-on: ubuntu-latest
timeout-minutes: 20
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess 2 mins should be enough?

outputs:
new_tag: ${{ steps.detect_then_tag.outputs.tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Detect and tag new version
id: detect_then_tag
uses: salsify/action-detect-and-tag-new-version@v2
create_github_release:
if: ${{ needs.create_git_tag.outputs.new_tag }}
name: Create new GitHub release
needs: create_git_tag
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: ncipollo/release-action@v1
with:
name: Release ${{ needs.create_git_tag.outputs.new_tag }}
tag: ${{ needs.create_git_tag.outputs.new_tag }}
publish_npm:
if: ${{ needs.create_git_tag.outputs.new_tag }}
name: Publish to NPM
needs: create_git_tag
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
registry-url: https://registry.npmjs.org
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_automation_token }}
36 changes: 36 additions & 0 deletions .github/workflows/update-emoji.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Update emoji

on:
schedule:
- cron: "0 2 * * *"

jobs:
push_update_pull_request:
name: Push update emoji pull-request
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Build new emoji files
run: npm run build
- name: Create Pull Request
id: create-pull-request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.github_write_token }}
commit-message: Update emoji
branch: update-emoji
title: "[Bot] Update emoji"
- name: Enable Pull Request Automerge
if: steps.create-pull-request.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v1
with:
token: ${{ secrets.github_repo_token }}
pull-request-number: ${{ steps.create-pull-request.outputs.pull-request-number }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp
2 changes: 1 addition & 1 deletion emoji-compact.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion emoji.json

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
"description": "Just an emoji.json.",
"main": "emoji.json",
"scripts": {
"build": "node scripts/gen.js",
"build": "./scripts/gen.sh",
"prepack": "npm run build"
},
"repository": "amio/emoji.json",
"repository": "https://github.com/amio/emoji.json",
"author": "Amio <[email protected]>",
"contributors": [
{
"name": "Guillaume Gérard",
"url": "https://guillaume.sh"
}
],
"license": "MIT",
"bugs": "https://github.com/amio/emoji.json/issues",
"homepage": "https://github.com/amio/emoji.json#readme",
Expand Down
8 changes: 7 additions & 1 deletion scripts/gen.js → scripts/build.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/usr/bin/env node

const fs = require('fs')
const path = require('path')
const https = require('https')

const EMOJI_VERSION = '13.1'
const EMOJI_VERSION = process.env.EMOJI_VERSION

main()

async function main () {
if (EMOJI_VERSION === undefined) {
throw new Error('Please specify EMOJI_VERSION')
}

const text = await getTestFile(EMOJI_VERSION)

console.log(`Format text to json...`)
Expand Down
13 changes: 13 additions & 0 deletions scripts/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh

mkdir -p tmp

wget https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt -O tmp/emoji-data.txt

FULL_VERSION=`head -n1 tmp/emoji-data.txt | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+"`
EMOJI_VERSION=`head -n1 tmp/emoji-data.txt | grep -E -o "[0-9]+\.[0-9]+"`

rm -rf tmp

npm version $FULL_VERSION --no-git-tag-version
EMOJI_VERSION=$EMOJI_VERSION node ./scripts/build.js