-
Notifications
You must be signed in to change notification settings - Fork 6
138 lines (116 loc) · 3.93 KB
/
release.yml
File metadata and controls
138 lines (116 loc) · 3.93 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: "Version tag to release (e.g. v1.2.3)"
required: true
permissions:
contents: write
jobs:
desktop:
runs-on: windows-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: apps/desktop/src-tauri -> target
- name: Extract version from tag
id: version
shell: bash
run: |
REF="${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}"
VERSION="${REF#v}"
VERSION_MSI="${VERSION%%-*}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "version_msi=$VERSION_MSI" >> "$GITHUB_OUTPUT"
echo "tag=${REF}" >> "$GITHUB_OUTPUT"
- name: Set version in tauri.conf.json
shell: bash
run: |
node -e "
const fs = require('fs');
const p = 'apps/desktop/src-tauri/tauri.conf.json';
const conf = JSON.parse(fs.readFileSync(p, 'utf-8'));
conf.version = '${{ steps.version.outputs.version_msi }}';
fs.writeFileSync(p, JSON.stringify(conf, null, 2) + '\n');
"
- run: pnpm install --frozen-lockfile
- run: pnpm build
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectPath: apps/desktop
args: --verbose
tagName: ${{ steps.version.outputs.tag }}
releaseName: "ADT Studio ${{ steps.version.outputs.tag }}"
releaseBody: ""
releaseDraft: false
prerelease: false
docker:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- name: Extract tag
id: version
run: |
REF="${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}"
echo "tag=${REF}" >> "$GITHUB_OUTPUT"
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
target: app
push: true
tags: |
ghcr.io/unicef/adt-studio:latest
ghcr.io/unicef/adt-studio:${{ steps.version.outputs.tag }}
- name: Ensure GitHub release exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ steps.version.outputs.tag }}"
gh release view "$TAG" --repo ${{ github.repository }} 2>/dev/null || \
gh release create "$TAG" --repo ${{ github.repository }} --title "ADT Studio $TAG" --notes ""
- name: Generate standalone docker-compose.yml
run: |
TAG="${{ steps.version.outputs.tag }}"
sed "s/__TAG__/${TAG}/g" docker/compose-release.yml.template > docker-compose.yml
- name: Upload docker-compose.yml to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ steps.version.outputs.tag }} docker-compose.yml \
--repo ${{ github.repository }} \
--clobber
- name: Generate release notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ steps.version.outputs.tag }}"
NOTES=$(gh api repos/${{ github.repository }}/releases/generate-notes \
-f tag_name="$TAG" \
--jq '.body')
gh release edit "$TAG" --notes "$NOTES"