@@ -11,110 +11,75 @@ jobs:
1111 contents : write
1212 name : Test / Build
1313 timeout-minutes : 30
14- runs-on : ubuntu-20.04
14+ runs-on : ubuntu-latest
1515 steps :
1616 - uses : actions/checkout@v4
1717 - run : git fetch --no-tags --depth=1 origin master
1818
19- - uses : actions/setup-node@v4
20- with :
21- node-version : " 22"
22-
2319 - name : Clone repo
2420 uses : actions/checkout@v4
2521 with :
2622 fetch-depth : 0
2723
28- - uses : pnpm/action-setup@v4
29- name : Install pnpm
30- id : pnpm-install
31- with :
32- version : 9
33- run_install : false
34-
35- - name : Get pnpm store directory
36- id : pnpm-cache
37- shell : bash
38- run : |
39- echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
40- - uses : actions/cache@v4
41- name : Setup pnpm cache
42- with :
43- path : ${{ steps.pnpm-cache.outputs.STORE_PATH }}
44- key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
45- restore-keys : |
46- ${{ runner.os }}-pnpm-store-
47- - name : Install dependencies
48- run : pnpm install --frozen-lockfile --strict-peer-dependencies
49-
50- - name : Lint
51- run : pnpm run lint
52-
53- - name : Type check
54- run : pnpm tsc --noemit
55-
56- - name : Run tests
57- run : pnpm test:coverage
58-
59- - name : Get previous commit hash
60- run : |
61- PREV_COMMIT=$(git log -1 --pretty=format:%H -- manifest.json)
62- echo "Previous commit hash is $PREV_COMMIT"
63- id : get-commit-hash
64-
65- - name : Get version number
66- run : |
67- VERSION=$(git show ${{ steps.get-commit-hash.outputs.PREV_COMMIT }}:manifest.json | grep version | awk -F'"' '{print $4}')
68- echo "Version number is $VERSION"
69- id : get-version
70-
71- - name : Get version labels
72- id : labels
73- run : |
74- commit_sha=$(git rev-parse HEAD)
75-
76- pull_request_number=$(git log --format='%s' -n 1 | grep -oP '(?<=Merge pull request #)\d+' || true)
77-
78- milestone=""
79-
80- if [[ -n "$pull_request_number" ]]; then
81- pull_request_info=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
82- "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${pull_request_number}")
83-
84- milestone=$(echo "$pull_request_info" | jq -r '.labels[].name' | grep -E 'major-version|minor-version' | head -1)
85- fi
86-
87- echo "milestone=${milestone}" >> $GITHUB_OUTPUT
88-
89- - name : Bump Version
24+ - name : Prep local dev
9025 run : |
91- git config --global user.name "git log -1 --pretty=format:%an"
26+ touch ~/.gitconfig
27+ mkdir ~/.ssh
28+ git config --global user.name "$(git log -1 --pretty=format:%an)"
9229 git config --global user.email "$(git log -1 --pretty=format:%ae)"
9330
94- if [ "$(git log -1 --pretty=format:%ae)" = "noreply@github.com" ]; then
95- echo "Skipping workflow run because previous commit was not made by workflow."
96- exit 0
97- fi
98-
99- if [[ "${{ steps.labels.outputs.milestone }}" == "major-version" ]]; then
100- pnpm run bumpManifestVer major ${{ steps.get-version.outputs.VERSION }}
101- elif [[ "${{ steps.labels.outputs.milestone }}" == "minor-version" ]]; then
102- pnpm run bumpManifestVer minor ${{ steps.get-version.outputs.VERSION }}
103- else
104- pnpm run bumpManifestVer patch ${{ steps.get-version.outputs.VERSION }}
105- fi
106-
107- pnpm prettier --write manifest.json
31+ - name : Export PR Labels
32+ id : extract_labels
33+ run : echo "labels=$(jq -r '[.[] | .name] | join(",")' <<< '${{ toJson(github.event.pull_request.labels) }}')" >> $GITHUB_OUTPUT
10834
35+ - name : Lint, Test, Build, and Tag
36+ uses : devcontainers/ci@v0.3
37+ env :
38+ LABELS : " ${{ steps.extract_labels.outputs.labels }}"
39+ with :
40+ env : LABELS
41+ runCmd : |
42+ set -e
43+
44+ # Lint
45+ pnpm run lint
46+ pnpm tsc --noemit
47+
48+ # Test
49+ pnpm test:coverage
50+
51+ # Build
52+ pnpm run build
53+
54+ # Tag
55+ if [ "$(git log -1 --pretty=format:%ae)" = "noreply@github.com" ]; then
56+ echo "Skipping workflow run because previous commit was made by workflow."
57+ exit 0
58+ fi
59+
60+ ## Get current version number
61+ PREV_COMMIT=$(git log -1 --pretty=format:%H -- manifest.json)
62+ VERSION=$(git show $PREV_COMMIT:manifest.json | grep version | head -n 1 | awk -F'"' '{print $4}')
63+ ## Get the commit message
64+ MILESTONE=$(echo "$LABELS" | grep -E 'major-version|minor-version' | head -1)
65+
66+ echo "Current Version is $VERSION and the milestone is $MILESTONE"
67+ if [[ "$MILESTONE" == "major-version" ]]; then
68+ pnpm run bumpManifestVer major $VERSION
69+ elif [[ "$MILESTONE" == "minor-version" ]]; then
70+ pnpm run bumpManifestVer minor $VERSION
71+ else
72+ pnpm run bumpManifestVer patch $VERSION
73+ fi
74+
75+ pnpm prettier --write manifest.json
76+
77+ - name : Update the Manifest in git
78+ run : |
10979 git add manifest.json
110-
11180 git commit -m "Updated Manifest"
112-
11381 git push origin master
11482
115- - name : Build
116- run : pnpm run build
117-
11883 - name : Package app zip
11984 working-directory : dist
12085 run : |
@@ -154,4 +119,3 @@ jobs:
154119 uses : DeskproApps/app-template-vite/.github/workflows/subworkflow-release.yml@master
155120 secrets : inherit
156121 needs : [deskpro_app_test_and_build]
157-
0 commit comments