Skip to content

Commit 97b3837

Browse files
committed
Add GitHub workflows
1 parent 5960d53 commit 97b3837

File tree

5 files changed

+209
-2
lines changed

5 files changed

+209
-2
lines changed

.github/workflows/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @lukaw3d @buberdds @csillag @lubej @ptrus

.github/workflows/ci-build.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
2+
name: ci-build
3+
4+
# Trigger the workflow when:
5+
on:
6+
# A push occurs to one of the matched branches.
7+
push:
8+
branches:
9+
- master
10+
- stable/*
11+
# Or when a pull request event occurs for a pull request against one of the
12+
# matched branches.
13+
pull_request:
14+
branches:
15+
- master
16+
- stable/*
17+
18+
jobs:
19+
build:
20+
# NOTE: This name appears in GitHub's Checks API.
21+
name: build
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
with:
27+
submodules: true
28+
- name: Set up Node.js 20
29+
uses: actions/setup-node@v6
30+
with:
31+
node-version: "20.x"
32+
cache: yarn
33+
- name: Install dependencies
34+
run: yarn install --frozen-lockfile
35+
- name: Set workflow variables
36+
# Id is needed to access output in a next step.
37+
id: vars
38+
run: |
39+
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
40+
- name: Build app
41+
run: yarn build
42+
- name: Upload build artifacts
43+
# Upload build artifacts on push event.
44+
if: github.event_name == 'push'
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: csv-exporter-${{ steps.vars.outputs.SHORT_SHA }}
48+
path: dist

.github/workflows/ci-lint.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
2+
name: ci-lint
3+
4+
# Trigger the workflow when:
5+
on:
6+
# A push occurs to one of the matched branches.
7+
push:
8+
branches:
9+
- master
10+
- stable/*
11+
# Or when a pull request event occurs for a pull request against one of the
12+
# matched branches.
13+
pull_request:
14+
branches:
15+
- master
16+
- stable/*
17+
18+
jobs:
19+
lint:
20+
# NOTE: This name appears in GitHub's Checks API.
21+
name: lint
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
with:
27+
submodules: true
28+
# Checkout pull request HEAD commit instead of merge commit.
29+
ref: ${{ github.event.pull_request.head.sha }}
30+
# Fetch all history so gitlint can check the relevant commits.
31+
fetch-depth: "0"
32+
- name: Set up Python 3
33+
uses: actions/setup-python@v6
34+
with:
35+
python-version: "3.x"
36+
- name: Set up Node.js 20
37+
uses: actions/setup-node@v6
38+
with:
39+
node-version: "20.x"
40+
cache: yarn
41+
- name: Install dependencies
42+
run: yarn install --frozen-lockfile
43+
- name: Install gitlint
44+
run: |
45+
python -m pip install gitlint
46+
# Needed for Towncrier fork to work with 3.12 and above
47+
- name: Install setuptools
48+
run: |
49+
python -m pip install setuptools
50+
- name: Install towncrier
51+
run: |
52+
python -m pip install https://github.com/oasisprotocol/towncrier/archive/oasis-master.tar.gz
53+
- name: Check for presence of a Change Log fragment (only pull requests)
54+
# NOTE: The pull request' base branch needs to be fetched so towncrier
55+
# is able to compare the current branch with the base branch.
56+
# Source: https://github.com/actions/checkout/#fetch-all-branches.
57+
run: |
58+
git fetch --no-tags origin "+refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH}"
59+
towncrier check --compare-with "origin/${BASE_BRANCH}"
60+
env:
61+
BASE_BRANCH: ${{ github.base_ref }}
62+
if: github.event_name == 'pull_request'
63+
- name: Lint documentation
64+
run: |
65+
yarn lint-docs
66+
# Always run this step so that all linting errors can be seen at once.
67+
if: always()
68+
- name: Lint Change Log fragments
69+
run: |
70+
yarn lint-changelog
71+
# Always run this step so that all linting errors can be seen at once.
72+
if: always()
73+
- name: Lint git commits
74+
run: |
75+
yarn lint-git
76+
# Always run this step so that all linting errors can be seen at once.
77+
if: always()
78+
- name: Prettier
79+
run: yarn prettier-check
80+
# Always run this step so that all linting errors can be seen at once.
81+
if: always()
82+
- name: ESLint
83+
# Disallow warnings and always throw errors.
84+
run: yarn lint --max-warnings 0
85+
# Always run this step so that all linting errors can be seen at once.
86+
if: always()
87+
- name: Validate TypeScript
88+
run: yarn checkTs
89+
# Always run this step so that all linting errors can be seen at once.
90+
if: always()

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
2+
name: release
3+
4+
# Trigger the workflow when:
5+
on:
6+
# A push occurs to one of the matched tags.
7+
push:
8+
tags:
9+
# Pattern that roughly matches Oasis Core's version tags.
10+
# For more details on GitHub Actions' pattern match syntax, see:
11+
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#patterns-to-match-branches-and-tags.
12+
- "v[0-9]+.[0-9]+*"
13+
14+
jobs:
15+
release:
16+
# NOTE: This name appears in GitHub's Checks API.
17+
name: prepare-release
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
submodules: true
26+
- name: Set up Node.js 20
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: "20.x"
30+
cache: yarn
31+
- name: Install dependencies
32+
run: yarn install --frozen-lockfile
33+
- name: Build app
34+
run: yarn build
35+
- name: Set workflow variables
36+
# Id is needed to access output in a next step.
37+
id: vars
38+
env:
39+
# There's no support for escaping this for use in a shell command.
40+
# GitHub's recommendation is to pass it through the environment.
41+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
42+
REF_NAME: ${{ github.ref_name }}
43+
# We want to show version without the leading 'v'
44+
# and use short SHA of the commit for file name.
45+
run: |
46+
echo "VERSION=$(echo "$REF_NAME" | sed 's/^v//')" >> "$GITHUB_OUTPUT"
47+
- name: Create zip file
48+
env:
49+
# Need to escape again
50+
VERSION: ${{ steps.vars.outputs.VERSION }}
51+
run: |
52+
cd dist/
53+
zip -r "../csv-exporter-$VERSION.zip" .
54+
- name: Parse CHANGELOG.md file and extract changes for the given version
55+
uses: buberdds/extract-changelog-action@v1
56+
id: changelog
57+
with:
58+
version: ${{ steps.vars.outputs.VERSION }}
59+
- name: Release
60+
uses: softprops/action-gh-release@v2
61+
with:
62+
files: |
63+
csv-exporter-${{ steps.vars.outputs.VERSION }}.zip
64+
name: CSV Exporter ${{ steps.vars.outputs.VERSION }}
65+
body: ${{ steps.changelog.outputs.content }}
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
"lint": "eslint src/",
1515
"lint:fix": "eslint src/ --fix",
1616
"format": "prettier --write src/",
17-
"format:check": "prettier --check src/",
18-
"lint-changelog": "markdownlint --config .changelog/.markdownlint.yml .changelog/"
17+
"prettier-check": "prettier --check src/",
18+
"lint-changelog": "markdownlint --config .changelog/.markdownlint.yml .changelog/",
19+
"checkTs": "tsc --noEmit"
1920
},
2021
"dependencies": {
2122
"axios": "^1.7.9",

0 commit comments

Comments
 (0)