@@ -13,12 +13,86 @@ permissions:
1313jobs :
1414 configure :
1515 runs-on : ubuntu-latest
16+ outputs :
17+ current_version : ${{ steps.current_version.outputs.result }}
18+ latest_published_version : ${{ steps.latest_published_version.outputs.result }}
19+ is_release : ${{ steps.current_version.outputs.result != steps.latest_published_version.outputs.result }}
1620 steps :
1721 - name : Checkout Repository
1822 uses : actions/checkout@v4
23+ - name : Get Package Version
24+ id : current_version
25+ run : echo "result=$(cat package.json | jq -r .version)" | sudo tee -a "$GITHUB_OUTPUT"
1926 - name : Run Script
2027 uses : actions/github-script@v7
28+ id : latest_published_version
2129 with :
30+ result-encoding : string
2231 script : |
23- const { getLatestVersion } = await import('${{ github.workspace }}/.github/scripts/lib.js');
24- await getLatestVersion();
32+ const { getLatestPublishedVersion } = await import('${{ github.workspace }}/.github/scripts/lib.js');
33+ return await getLatestPublishedVersion({ context, exec, github });
34+ build :
35+ runs-on : ubuntu-latest
36+ needs : [configure]
37+ env :
38+ CURRENT_VERSION : ${{ needs.configure.outputs.current_version }}
39+ strategy :
40+ fail-fast : true
41+ matrix :
42+ include :
43+ - dockerfile : ./apps/api/Dockerfile
44+ image : ghcr.io/douglasneuroinformatics/open-data-capture-api
45+ - dockerfile : ./apps/gateway/Dockerfile
46+ image : ghcr.io/douglasneuroinformatics/open-data-capture-gateway
47+ - dockerfile : ./apps/web/Dockerfile
48+ image : ghcr.io/douglasneuroinformatics/open-data-capture-web
49+ if : ${{ needs.configure.is_release }}
50+ steps :
51+ - name : Checkout Repository
52+ uses : actions/checkout@v4
53+ - name : Setup Environment
54+ run : ./scripts/generate-env.sh
55+ - name : Set Up QEMU
56+ uses : docker/setup-qemu-action@v3
57+ - name : Set Up Docker Buildx
58+ uses : docker/setup-buildx-action@v3
59+ - name : Login to Container Registry
60+ uses : docker/login-action@v3
61+ with :
62+ registry : ghcr.io
63+ username : ${{ github.repository_owner }}
64+ password : ${{ secrets.GITHUB_TOKEN }}
65+ - name : Extract Metadata for Docker
66+ id : meta
67+ uses : docker/metadata-action@v5
68+ with :
69+ images : ${{ matrix.image }}
70+ tags : |
71+ type=raw,value=latest
72+ type=raw,value=${{ needs.configure.outputs.current_version }}
73+ - name : Build and Push Docker Images
74+ uses : docker/build-push-action@v6
75+ with :
76+ context : .
77+ file : ${{ matrix.dockerfile }}
78+ push : true
79+ platforms : linux/amd64,linux/arm64
80+ tags : ${{ steps.meta.outputs.tags }}
81+ labels : ${{ steps.meta.outputs.labels }}
82+ release :
83+ runs-on : ubuntu-latest
84+ needs :
85+ - build
86+ - configure
87+ permissions :
88+ contents : write
89+ env :
90+ CURRENT_VERSION : ${{ needs.configure.outputs.current_version }}
91+ if : ${{ needs.configure.is_release }}
92+ steps :
93+ - name : Checkout Repository
94+ uses : actions/checkout@v4
95+ - name : Create Release
96+ uses : softprops/action-gh-release@v2
97+ with :
98+ tag_name : v${{ env.CURRENT_VERSION }}
0 commit comments