Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit eacd41a

Browse files
Merge pull request #145 from rtfpessoa/test-actions
test actions
2 parents 46681d0 + bdb1769 commit eacd41a

File tree

4 files changed

+172
-203
lines changed

4 files changed

+172
-203
lines changed

‎.circleci/config.yml‎

Lines changed: 0 additions & 203 deletions
This file was deleted.

‎.github/workflows/ci.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
jobs:
8+
test-and-publish:
9+
uses: ./.github/workflows/test-and-publish.yml
10+
with:
11+
environment: dev
12+
secrets: inherit

‎.github/workflows/release.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
jobs:
8+
test-and-publish:
9+
uses: ./.github/workflows/test-and-publish.yml
10+
with:
11+
environment: production
12+
secrets: inherit
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: test-and-publish
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
version:
12+
runs-on: ubuntu-latest
13+
container:
14+
image: codacy/git-version
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
- name: Fix tar access
20+
run: apk add --update --no-progress tar
21+
- name: Fix git access
22+
run: |
23+
git config --global --add safe.directory /__w/diff2html-cli/diff2html-cli
24+
- name: Get next version
25+
run: |
26+
export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=master)"
27+
echo "Next version is ${NEXT_VERSION}"
28+
echo "${NEXT_VERSION}" > .version
29+
echo "version=${NEXT_VERSION}" >> $GITHUB_ENV
30+
- name: Get next npm tag name
31+
run: |
32+
if [ "${GITHUB_REF_NAME}" = "master" ]; then
33+
export PUBLISH_TAG="latest"
34+
elif [ "${GITHUB_REF_NAME}" = "next" ]; then
35+
export PUBLISH_TAG="next"
36+
else
37+
export PUBLISH_TAG="pr"
38+
fi
39+
echo "Next tag is ${PUBLISH_TAG}"
40+
echo "${PUBLISH_TAG}" > .tag
41+
- name: Upload versions
42+
uses: actions/upload-artifact@v3
43+
with:
44+
name: versions
45+
if-no-files-found: error
46+
path: |
47+
.version
48+
.tag
49+
50+
build:
51+
runs-on: ubuntu-latest
52+
needs: [version]
53+
strategy:
54+
matrix:
55+
node-version: [14.x, 16.x, 18.x]
56+
steps:
57+
- uses: actions/checkout@v3
58+
with:
59+
fetch-depth: 0
60+
- name: Use Node.js ${{ matrix.node-version }}
61+
uses: actions/setup-node@v3
62+
with:
63+
node-version: ${{ matrix.node-version }}
64+
cache: 'yarn'
65+
- name: Log environment setup
66+
run: |
67+
node -v
68+
yarn -v
69+
- name: Install dependencies
70+
run: yarn install --ignore-engines
71+
- name: Build library
72+
run: yarn run validate
73+
74+
publish:
75+
runs-on: ubuntu-latest
76+
needs: [build]
77+
environment: ${{ inputs.environment }}
78+
steps:
79+
- uses: actions/checkout@v3
80+
with:
81+
fetch-depth: 0
82+
- name: Download versions
83+
uses: actions/download-artifact@v3
84+
with:
85+
name: versions
86+
- name: Store version
87+
run: echo "version=$(cat .version)" >> $GITHUB_ENV
88+
- name: Configure Git
89+
run: |
90+
git config user.email "gh-actions@users.noreply.github.com"
91+
git config user.name "GitHub Actions"
92+
- name: Tag commit
93+
uses: tvdias/github-tagger@v0.0.1
94+
with:
95+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
96+
tag: "${{ env.version }}"
97+
- name: Install dependencies
98+
run: yarn
99+
- uses: actions/setup-node@v3
100+
with:
101+
registry-url: 'https://registry.npmjs.org'
102+
node-version: '18.x'
103+
- name: Configure Yarn version
104+
env:
105+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
106+
run: |
107+
rm -f .npmrc
108+
touch .npmrc
109+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc
110+
echo "registry=https://registry.npmjs.org/" >> .npmrc
111+
echo "access=public" >> .npmrc
112+
echo "save-exact=true" >> .npmrc
113+
yarn config set version-tag-prefix ""
114+
yarn config set version-git-message "Release version %s"
115+
- name: Version package
116+
run: |
117+
# Update version in packages to publish
118+
yarn version --non-interactive --new-version $(cat .version)
119+
- name: Publish to NPM
120+
run: yarn publish --tag $(cat .tag) --non-interactive --new-version $(cat .version)
121+
- uses: actions/setup-node@v3
122+
with:
123+
node-version: '18.x'
124+
registry-url: 'https://npm.pkg.github.com'
125+
- name: Configure Yarn version
126+
env:
127+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
run: |
129+
rm -f .npmrc
130+
touch .npmrc
131+
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc
132+
echo "@rtfpessoa:registry=https://npm.pkg.github.com/" >> .npmrc
133+
echo "access=public" >> .npmrc
134+
echo "save-exact=true" >> .npmrc
135+
yarn config set version-tag-prefix ""
136+
yarn config set version-git-message "Release version %s"
137+
- name: Version package
138+
run: |
139+
# Update version in packages to publish
140+
yarn version --non-interactive --new-version $(cat .version)
141+
- name: Publish to GPR
142+
run: |
143+
# HACK: Override npm package name to be able to publish in GitHub
144+
sed -i 's/^ "name":.*/ "name": "@rtfpessoa\/diff2html-cli",/g' package.json
145+
echo "Going to publish version $(cat .version) to GitHub"
146+
yarn publish --tag $(cat .tag) --non-interactive --new-version $(cat .version)
147+
# HACK: Restore npm package name
148+
sed -i 's/^ "name":.*/ "name": "diff2html-cli",/g' package.json

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /