-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (119 loc) · 3.97 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: CI
on:
push:
branches:
- main
pull_request:
- main
defaults:
run:
shell: bash
jobs:
unit_test:
name: Unit test
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
submodules: "true"
- run: npm install -g bats
- name: Install Bats
run: bats -v
- name: Run unit tests
run: bats ./test
deb_package:
name: Build debian package (artifact)
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt install --yes --no-install-recommends lintian dpkg gzip
- name: Print dependecies info
run: |
dpkg-deb --version
gzip --version
lintian --version
- name: Build deb archive
run: bash ci/make_deb_archive.sh
- name: Lint deb archive
run: lintian --fail-on warning --no-tag-display-limit release/*.deb
- name: Upload deb package artifact
uses: actions/upload-artifact@v3
with:
name: deb-package
path: release/*.deb
if-no-files-found: error
retention-days: 5
version_check:
runs-on: ubuntu-latest
outputs:
latest_tag: ${{ steps.check.outputs.latest_tag }}
source_version: ${{ steps.check.outputs.source_version }}
is_release: ${{ steps.check.outputs.is_release }}
steps:
- name: Checkout repository code
uses: actions/checkout@v3
- name: Fetch tags
# I've noticed sometimes checkout doesnt fetch tags
run: git fetch --tags
- name: Check Versions
id: check
run: |
v=( $(bash ci/get_versions.sh) )
echo "latest_tag=${v[0]} source_version=${v[1]} is_release=${v[2]}"
echo "latest_tag=${v[0]}" >> "$GITHUB_OUTPUT"
echo "source_version=${v[1]}" >> "$GITHUB_OUTPUT"
echo "is_release=${v[2]}" >> "$GITHUB_OUTPUT"
# Released source archive has a different sha 256 from git archive
# Thus I cant pre-computed, and must generate homebrew formula post release
#homebrew_formula:
# runs-on: ubuntu-latest
# needs: [version_check]
# if: success()
# env:
# VERSION: ${{needs.version_check.outputs.source_version}}
# steps:
# - name: Check out repository code
# uses: actions/checkout@v3
# - name: Create Homebrew formula
# run: |
# SHA256=$(git archive --format=tar.gz -v -6 HEAD | sha256sum | cut -d ' ' -f 1)
# echo "$SHA256"
# FORMULA_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${VERSION}.tar.gz"
# bash ci/make_formula.sh "$FORMULA_URL" "$SHA256" "$VERSION"
# - name: Upload Homebrew formula artifact
# uses: actions/upload-artifact@v3
# with:
# name: homebrew-formula
# path: release/*.rb
# if-no-files-found: error
# retention-days: 5
release:
runs-on: ubuntu-latest
needs: [version_check, deb_package, unit_test]
if: success() && github.ref_name == 'main' && needs.version_check.outputs.is_release == 'true'
env:
VERSION: ${{needs.version_check.outputs.source_version}}
GH_TOKEN: ${{ secrets.JOURNALSCRIPT_WORKFLOW_TRIGGER_PAT }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
with:
path: release/
- name: Create Release Log
run: bash ci/extract_latest_release.sh CHANGELOG.md > release/RELEASE_LOG.md
- name: Display structure of downloaded files
run: |
ls -R ${{ github.workspace }}
cat release/RELEASE_LOG.md
- name: Release
id: release
run: |
gh release create ${VERSION} \
--notes-file release/RELEASE_LOG.md \
--title "Journalscript ${VERSION}" \
release/deb-package/*.deb