Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Commit b2da6fa

Browse files
committed
ci: add reusable workflows for all jobs
1 parent a828203 commit b2da6fa

File tree

15 files changed

+293
-234
lines changed

15 files changed

+293
-234
lines changed

.github/workflows/cd.yml

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

.github/workflows/ci.yml

+57
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 change in documentation
30+
id: changed_doc
31+
if: steps.check_version_bump.outputs.release_type == ''
32+
uses: tj-actions/[email protected]
33+
with:
34+
files: |
35+
Sources/**/*
36+
Package*.swift
37+
.github/workflows/ci.yml
38+
39+
- name: Setup repository
40+
if: steps.changed_doc.outputs.any_changed == 'true'
41+
uses: ./.github/actions/setup
42+
43+
- name: Build package documentation
44+
if: steps.changed_doc.outputs.any_changed == 'true'
45+
run: |
46+
npm run build
47+
npm run serve-doc
48+
49+
- name: Update GitHub Pages
50+
if: steps.changed_doc.outputs.any_changed == '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 }}'

.github/workflows/cocoapods.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Run CocoaPods Linting"
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
# Lint podspec with latest Xcode and Swift version
8+
cocoapods:
9+
name: Run CocoaPods Linting on latest macos
10+
runs-on: macos-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: Check change in source files
17+
id: changed_source
18+
uses: tj-actions/[email protected]
19+
with:
20+
files: |
21+
Sources/**/*
22+
Tests/**/*
23+
*.podspec
24+
.github/actions/setup/action.yml
25+
.github/workflows/cocoapods.yml
26+
27+
- name: Setup repository
28+
if: steps.changed_source.outputs.any_changed == 'true'
29+
uses: ./.github/actions/setup
30+
31+
- name: Run tests
32+
if: steps.changed_source.outputs.any_changed == 'true'
33+
run: npm run pod-lint

0 commit comments

Comments
 (0)