Skip to content

Commit bf8ae3d

Browse files
committed
ci: add CI/CD pipeline actions
1 parent 9e69dbb commit bf8ae3d

31 files changed

+3196
-0
lines changed

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: [soumyamahunt] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Get last run status for workflow
2+
description: Get last run status for workflow
3+
inputs:
4+
workflow:
5+
description: Workflow id to check status of
6+
required: false
7+
default: main.yml
8+
files:
9+
description: Check if the files changed
10+
required: true
11+
outputs:
12+
proceed:
13+
description: Should proceed running steps
14+
value: ${{ steps.changed_files.outputs.any_changed == 'true' || steps.last_status.outputs.result != 'true' }}
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Check change in files
19+
id: changed_files
20+
uses: tj-actions/[email protected]
21+
with:
22+
files: ${{ inputs.files }}
23+
24+
- name: Get last run
25+
if: steps.changed_files.outputs.any_changed != 'true'
26+
id: last_status
27+
uses: actions/[email protected]
28+
env:
29+
WORKFLOW: ${{ inputs.workflow }}
30+
with:
31+
result-encoding: json
32+
script: |
33+
const { GITHUB_REF_NAME, WORKFLOW } = process.env;
34+
core.startGroup(`Checking last status for workflow \`${WORKFLOW}\` for branch \`${GITHUB_REF_NAME}\``);
35+
const result = await github.rest.actions.listWorkflowRuns({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
workflow_id: WORKFLOW,
39+
branch: GITHUB_REF_NAME,
40+
per_page: 2,
41+
page: 1
42+
});
43+
core.info(JSON.stringify(result));
44+
core.endGroup();
45+
const currentConclusion = result.data.workflow_runs[0]?.conclusion;
46+
const success = (currentConclusion ? (currentConclusion === 'success') : true) &&
47+
(result.data.workflow_runs[1]?.conclusion === 'success');
48+
return success;

.github/actions/setup/action.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Setup action for Swift library
2+
description: Setup action for Swift library `AsyncObject`
3+
inputs:
4+
swift:
5+
description: Swift version to use
6+
required: false
7+
default: '5.6'
8+
xcode:
9+
description: Xcode version to use
10+
required: false
11+
default: latest
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Setup Xcode version
16+
if: runner.os == 'macOS'
17+
uses: maxim-lobanov/[email protected]
18+
with:
19+
xcode-version: ${{ inputs.xcode }}
20+
21+
- name: Setup Cocoapods
22+
if: runner.os == 'macOS'
23+
uses: maxim-lobanov/setup-cocoapods@v1
24+
with:
25+
version: latest
26+
27+
- name: Setup swift
28+
if: runner.os == 'Linux' || runner.os == 'Windows'
29+
uses: soumyamahunt/setup-swift@win-support
30+
with:
31+
swift-version: ${{ inputs.swift }}
32+
33+
- name: Setup node
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: '17'
37+
38+
- name: Setup npm pacakges
39+
if: steps.check_version_bump.outputs.release_type == ''
40+
run: npm install
41+
shell: bash

.github/config/config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict'
2+
const config = require('conventional-changelog-conventionalcommits');
3+
4+
module.exports = config({
5+
"types": [
6+
{ type: 'feat', section: '🚀 Features' },
7+
{ type: 'fix', section: '🐛 Fixes' },
8+
{ type: 'perf', section: '🐎 Performance Improvements' },
9+
{ type: 'revert', section: '⏪ Reverts' },
10+
{ type: 'build', section: '🛠 Build System' },
11+
{ type: 'deps', section: '🛠 Dependency' },
12+
{ type: 'refactor', section: '🔥 Refactorings' },
13+
{ type: 'doc', section: '📚 Documentation' },
14+
{ type: 'docs', section: '📚 Documentation' },
15+
{ type: 'style', section: '💄 Styles' },
16+
{ type: 'test', section: '✅ Tests' },
17+
{ type: 'ci', section: '💡 Continuous Integration', hidden: true },
18+
{ type: 'wip', hidden: true },
19+
{ type: 'chore', hidden: true },
20+
]
21+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const semver = require('semver');
2+
const core = require('@actions/core');
3+
4+
exports.preVersionGeneration = (version) => {
5+
const { VERSION } = process.env;
6+
core.info(`Computed version bump: ${version}`);
7+
8+
const newVersion = semver.valid(VERSION);
9+
if (newVersion) {
10+
version = newVersion;
11+
core.info(`Using provided version: ${version}`);
12+
}
13+
return version;
14+
};
15+
16+
exports.preTagGeneration = (tag) => { };

.github/config/pre_commit_hook.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { execSync } = require('child_process');
2+
const core = require('@actions/core');
3+
4+
exports.preCommit = (props) => {
5+
core.startGroup(`Running \`npm install\``);
6+
execSync(
7+
'npm install', {
8+
stdio: ['inherit', 'inherit', 'inherit'],
9+
encoding: 'utf-8'
10+
}
11+
);
12+
core.endGroup();
13+
14+
execSync(
15+
'npm run generate', {
16+
stdio: ['inherit', 'inherit', 'inherit'],
17+
encoding: 'utf-8'
18+
}
19+
);
20+
};

.github/config/spellcheck.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
matrix:
2+
- name: Markdown
3+
aspell:
4+
lang: en
5+
d: en_US
6+
dictionary:
7+
encoding: utf-8
8+
# wordlists:
9+
# - .github/config/custom-words.txt
10+
# output: .build/dictionary/custom-words.dic
11+
pipeline:
12+
- pyspelling.filters.markdown:
13+
- pyspelling.filters.html:
14+
comments: false
15+
ignores:
16+
- code
17+
- pre
18+
sources:
19+
- '**/*.md'
20+
default_encoding: utf-8

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2
2+
enable-beta-ecosystems: true
3+
updates:
4+
# - package-ecosystem: swift-package
5+
# directory: /
6+
# schedule:
7+
# interval: weekly
8+
# commit-message:
9+
# prefix: 'deps: '
10+
11+
- package-ecosystem: github-actions
12+
directory: /
13+
schedule:
14+
interval: monthly
15+
commit-message:
16+
prefix: 'ci(Deps): '
17+
18+
- package-ecosystem: npm
19+
directory: /
20+
schedule:
21+
interval: monthly
22+
commit-message:
23+
prefix: 'ci(Deps): '

.github/workflows/cd.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: "Check if release needed"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: New version to release
8+
required: false
9+
type: string
10+
11+
jobs:
12+
cd:
13+
name: Build and Publish
14+
runs-on: macos-12
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
- name: Setup Ruby
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: 2.7
24+
25+
- name: Setup repository
26+
uses: ./.github/actions/setup
27+
28+
- name: Conventional Changelog Action
29+
id: conventional_changelog
30+
uses: TriPSs/conventional-changelog-action@v3
31+
with:
32+
github-token: ${{ github.token }}
33+
git-message: 'chore(CHANGELOG): update for {version}'
34+
git-user-name: ${{ github.actor }}
35+
git-user-email: [email protected]
36+
release-count: 0
37+
version-file: './package.json'
38+
version-path: version
39+
fallback-version: '1.0.0'
40+
config-file-path: '.github/config/config.js'
41+
pre-commit: '.github/config/pre_commit_hook.js'
42+
pre-changelog-generation: '.github/config/pre_changelog_hook.js'
43+
env:
44+
VERSION: ${{ inputs.version }}
45+
46+
- name: Build package products and documentation
47+
if: steps.conventional_changelog.outputs.skipped == 'false'
48+
run: |
49+
npm run build
50+
npm run build-doc
51+
npm run serve-doc
52+
npm run archive
53+
54+
- name: Release GitHub Pages
55+
if: steps.conventional_changelog.outputs.skipped == 'false'
56+
continue-on-error: true
57+
uses: JamesIves/[email protected]
58+
with:
59+
branch: gh-pages
60+
folder: .docc-build
61+
target-folder: docs
62+
clean: false
63+
commit-message: 'chore(GitHub Pages): release site for tag ${{ steps.conventional_changelog.outputs.tag }}'
64+
65+
- name: Create GitHub Release
66+
if: steps.conventional_changelog.outputs.skipped == 'false'
67+
continue-on-error: true
68+
uses: ncipollo/release-action@v1
69+
with:
70+
token: ${{ github.token }}
71+
tag: ${{ steps.conventional_changelog.outputs.tag }}
72+
body: ${{ steps.conventional_changelog.outputs.changelog }}
73+
artifacts: '*.zip'
74+
75+
- name: Publish to CocoaPods trunk
76+
if: steps.conventional_changelog.outputs.skipped == 'false'
77+
continue-on-error: true
78+
run: |
79+
set -eo pipefail
80+
pod trunk push --skip-import-validation --skip-tests --allow-warnings
81+
env:
82+
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
83+
84+
- name: Publish to Swift Package Registry
85+
if: steps.conventional_changelog.outputs.skipped == 'false'
86+
continue-on-error: true
87+
uses: twodayslate/[email protected]

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Check if release needed"
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
release:
7+
description: "Whether release is needed or not"
8+
value: ${{ jobs.ci.outputs.release }}
9+
10+
jobs:
11+
ci:
12+
name: Check if release needed
13+
runs-on: ubuntu-latest
14+
outputs:
15+
release: ${{ steps.check_version_bump.outputs.release_type != '' }}
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
21+
- name: Check version bump
22+
id: check_version_bump
23+
uses: mathieudutour/[email protected]
24+
with:
25+
github_token: ${{ github.token }}
26+
default_bump: false
27+
dry_run: true
28+
29+
- name: Check should proceed running steps
30+
if: steps.check_version_bump.outputs.release_type == ''
31+
id: precondition
32+
uses: ./.github/actions/condition
33+
with:
34+
files: |
35+
Sources/**/*
36+
Package*.swift
37+
.github/workflows/ci.yml
38+
39+
- name: Setup repository
40+
if: steps.precondition.outputs.proceed == 'true'
41+
uses: ./.github/actions/setup
42+
43+
- name: Build package documentation
44+
if: steps.precondition.outputs.proceed == 'true'
45+
run: |
46+
npm run build
47+
npm run serve-doc
48+
49+
- name: Update GitHub Pages
50+
if: steps.precondition.outputs.proceed == 'true'
51+
uses: JamesIves/[email protected]
52+
with:
53+
branch: gh-pages
54+
folder: .docc-build
55+
target-folder: docs
56+
clean: false
57+
commit-message: 'chore(GitHub Pages): update site for commit ${{ github.sha }}'

0 commit comments

Comments
 (0)