-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (144 loc) · 6.21 KB
/
release.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Release
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '.github/**'
- '!.github/workflows/release.yml'
- '!.github/workflows/test.yml'
- '.vscode/**'
- 'cli/**'
- '!cli/web_deploy_monitor.sh'
- 'docs/**'
- 'LICENSE'
- 'README.md'
permissions:
contents: write
jobs:
trigger-test:
uses: ./.github/workflows/test.yml
release:
strategy:
matrix:
include:
- build: web
os: ubuntu-latest
build-folder: build
build-artifact: web
environment: onrender
- build: appbundle
os: ubuntu-latest
build-folder: build/app/outputs/bundle/release
build-artifact: app-release.aab
- build: macos
os: macos-latest
build-folder: build/macos/Build/Products/Release
build-artifact: sourdoc.app
- build: linux
os: ubuntu-latest
build-folder: build/linux/x64/release
build-artifact: bundle
- build: windows
os: windows-latest
build-folder: build/windows/x64/runner
build-artifact: release
name: release-${{ matrix.build }}
concurrency: build-${{ github.ref }}-${{ matrix.build }}
runs-on: ${{ matrix.os }}
needs: trigger-test
environment: ${{ matrix.environment }}
steps:
- name: '[linux] Install dependencies'
if: ${{ matrix.build == 'linux' }}
run: sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev
- name: '[appbundle] Setup java'
if: ${{ matrix.build == 'appbundle' }}
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: '[appbundle] Setup android sdk'
if: ${{ matrix.build == 'appbundle' }}
uses: android-actions/setup-android@v3
- name: Prepare flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ vars.FLUTTER_VERSION }}
channel: ${{ vars.FLUTTER_CHANNEL }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set environment variables
if: ${{ matrix.build != 'windows' }}
id: env_vars
run: |
echo -e "VERSION=$(cat VERSION)\nBUILD_NUMBER=$(date +%s)\nARTIFACT_NAME=${{ matrix.build }}-sourdoc-v$(cat VERSION)" >> $GITHUB_ENV
- name: '[windows] Set environment variables'
if: ${{ matrix.build == 'windows' }}
run: |
echo "VERSION=$(cat VERSION)`nBUILD_NUMBER=$(date +%s)`nARTIFACT_NAME=${{ matrix.build }}-sourdoc-v$(cat VERSION)" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: '[appbundle] Setup upload keystore'
if: ${{ matrix.build == 'appbundle' }}
run: |
echo "${{ secrets.ANDROID_UPLOAD_KEYSTORE_ASC }}" > $HOME/upload-keystore.jks.asc
gpg -d --passphrase "${{ secrets.ANDROID_UPLOAD_KEYSTORE_ASC_PASSPHRASE }}" --batch $HOME/upload-keystore.jks.asc > $HOME/upload-keystore.jks
echo -e "storePassword=${{ secrets.ANDROID_UPLOAD_KEYSTORE_PASSWORD }}\nkeyPassword=${{ secrets.ANDROID_UPLOAD_KEYSTORE_PASSWORD }}\nkeyAlias=upload\nstoreFile=$HOME/upload-keystore.jks" > android/key.properties
- name: Build release
run: flutter build -v ${{ matrix.build }} --release
--build-name=${{ env.VERSION }}
--build-number=${{ env.BUILD_NUMBER }}
--dart-define=VERSION=${{ env.VERSION }}
--dart-define=BUILD_NUMBER=${{ env.BUILD_NUMBER }}
--dart-define=COMMIT_SHA=${{ github.sha }}
--dart-define=REPO_URL=${{ github.server_url }}/${{ github.repository }}
${{ matrix.build == 'web' && '--csp' || ''}}
- name: '[web] Trigger deploy on Render'
if: ${{ matrix.build == 'web' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ${{ matrix.build-folder }}/${{ matrix.build-artifact }}
branch: onrender
- name: 'Compress build'
run: |
cd ${{ matrix.build-folder }}
tar -czf ${{ env.ARTIFACT_NAME }}.tgz ${{ matrix.build-artifact }}
- name: 'Upload build artifact'
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ matrix.build-folder }}/${{ env.ARTIFACT_NAME }}.tgz
if-no-files-found: error
outputs:
version: ${{ steps.env_vars.outputs.VERSION }}
build_number: ${{ steps.env_vars.outputs.BUILD_NUMBER }}
create-github-release:
concurrency: release-${{ github.ref }}
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.release.outputs.version }}
files: |
artifacts/**/*
fail_on_unmatched_files: true
monitor-web-deploy:
needs: release
runs-on: ubuntu-latest
env:
BUILD_NUMBER: ${{ needs.release.outputs.build_number }}
steps:
- name: Check deployment status
run: BUILD_NUMBER="$BUILD_NUMBER" bash cli/web_deploy_monitor.sh