Skip to content

Commit d1ae5ca

Browse files
authored
Relase action + issue template + better app name in release and settings (#29)
* ff * fixes * f * Update nightly_release.yml * f * fix * add commit hash in settings
1 parent bf02c49 commit d1ae5ca

File tree

10 files changed

+168
-62
lines changed

10 files changed

+168
-62
lines changed

.github/ISSUE_TEMPLATE/blank_issue.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
name: Blank Issue (do not use this for bug reports or feature requests)
3+
about: Create an issue with a blank template
4+
---

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Bug Report
3+
about: Report a correctness issue or violated expectation
4+
labels: bug
5+
---
6+
7+
#### Bug Description
8+
9+
#### Expected Result
10+
11+
#### Steps to Reproduce
12+
13+
#### Possible Solutions (optional)
14+
15+
#### Possible Additional Information (optional)
16+
17+
#### App version
18+
19+
#### Logs

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blank_issues_enabled: true
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Feature Request
3+
about: Request a feature
4+
labels: enhancement
5+
---
6+
7+
#### Use Case
8+
9+
#### Proposed Change
10+
11+
#### Who Benefits From The Change? (optional)
12+
13+
#### Alternative Approaches (optional)

.github/workflows/nightly_release.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Nightly Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
is_nightly:
7+
description: "Is nightly"
8+
required: false
9+
default: false
10+
type: boolean
11+
push:
12+
branches:
13+
- master
14+
paths-ignore:
15+
- "*.md"
16+
17+
concurrency:
18+
group: ${{ github.workflow }}
19+
cancel-in-progress: true
20+
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
GH_REPO: ${{ github.repository }}
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
CARGO_TERM_COLOR: always
26+
27+
28+
jobs:
29+
setup-env:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
app_version: ${{ steps.set_outputs.outputs.app_version }}
33+
tag_name: ${{ steps.set_outputs.outputs.tag_name }}
34+
version_name: ${{ steps.set_outputs.outputs.version_name }}
35+
prerelease: ${{ steps.set_outputs.outputs.prerelease }}
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Get app version
41+
run: echo "APP_VERSION=$(cat VERSION)" >> $GITHUB_ENV
42+
43+
- if: ${{ (github.event.inputs.is_nightly == 'true') || (github.event.inputs.is_nightly == '') }}
44+
name: Setup options for nightly
45+
run: |
46+
echo "TAG_NAME=nightly" >> $GITHUB_ENV
47+
echo "VERSION_NAME=${{ env.TAG_NAME }}" >> $GITHUB_ENV
48+
echo "PRERELEASE=--prerelease" >> $GITHUB_ENV
49+
50+
- if: ${{ github.event.inputs.is_nightly == 'false' }}
51+
name: Setup options for a new release
52+
run: |
53+
echo "TAG_NAME=v${{ env.APP_VERSION }}" >> $GITHUB_ENV
54+
echo "VERSION_NAME=${{ env.APP_VERSION }}" >> $GITHUB_ENV
55+
56+
- name: Set up outputs
57+
id: set_outputs
58+
run: |
59+
echo "app_version=${{ env.APP_VERSION }}" >> "$GITHUB_OUTPUT"
60+
echo "tag_name=${{ env.TAG_NAME }}" >> "$GITHUB_OUTPUT"
61+
echo "version_name=${{ env.VERSION_NAME }}" >> "$GITHUB_OUTPUT"
62+
echo "prerelease=${{ env.PRERELEASE }}" >> "$GITHUB_OUTPUT"
63+
64+
65+
upload-artifacts:
66+
needs: setup-env
67+
uses: ./.github/workflows/upload_artifacts.yml
68+
secrets: inherit
69+
with:
70+
version: ${{ needs.setup-env.outputs.version_name }}
71+
72+
publish:
73+
needs: [upload-artifacts, setup-env]
74+
runs-on: ubuntu-latest
75+
76+
permissions:
77+
contents: write
78+
79+
steps:
80+
- uses: actions/checkout@v4
81+
with:
82+
# https://github.com/actions/checkout/issues/1471
83+
fetch-tags: false
84+
85+
# must be after checkout because it will remove artifacts
86+
- uses: actions/download-artifact@v4
87+
88+
- name: Publish release
89+
run: |
90+
91+
# delete previous nightly release
92+
gh release delete nightly --yes || true
93+
git push --delete origin nightly || true
94+
95+
git tag ${{ needs.setup-env.outputs.tag_name }}
96+
git push origin --tags
97+
98+
# https://cli.github.com/manual/gh_release_create
99+
gh release create ${{ needs.setup-env.outputs.tag_name }} --title "${{ needs.setup-env.outputs.version_name }}" \
100+
--verify-tag ${{ needs.setup-env.outputs.prerelease }} --generate-notes --target $GITHUB_SHA \
101+
./gitnote/*

.github/workflows/upload_artifacts.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@ name: Upload Artifacts
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
version:
7+
required: false
8+
type: string
9+
default: "nightly"
510
workflow_call:
11+
inputs:
12+
version:
13+
required: true
14+
type: string
615

716
env:
817
CARGO_TERM_COLOR: always
@@ -51,5 +60,6 @@ jobs:
5160
5261
- uses: actions/upload-artifact@v4
5362
with:
54-
name: gitnote
63+
# todo: dynamic arch
64+
name: gitnote-release-${{ github.event.inputs.version }}-arm64-v8a.apk
5565
path: app/build/outputs/apk/release/*.apk

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24.05

app/build.gradle.kts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import java.io.BufferedReader
2+
import java.io.InputStreamReader
3+
14
plugins {
25
alias(libs.plugins.android.application)
36
alias(libs.plugins.kotlin.android)
@@ -17,8 +20,21 @@ android {
1720
minSdk = 33
1821
targetSdk = 34
1922
versionCode = 1
20-
versionName = "0.1.0"
23+
versionName = File("VERSION").readText()
24+
25+
fun getGitHash(): String {
26+
val command = "git rev-parse HEAD"
27+
val process = Runtime.getRuntime().exec(command)
28+
val reader = BufferedReader(InputStreamReader(process.inputStream))
2129

30+
return reader.readLine()
31+
}
32+
33+
buildConfigField(
34+
"String",
35+
"GIT_HASH",
36+
"\"${getGitHash()}\""
37+
)
2238

2339
resourceConfigurations.addAll(
2440
listOf(

app/src/main/java/io/github/wiiznokes/gitnote/ui/screen/settings/MainSettingsScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ fun MainSettingsScreen(
255255
isLast = true
256256
) {
257257
var version = BuildConfig.VERSION_NAME
258+
version += "-${BuildConfig.GIT_HASH.substring(0..7)}"
258259
version += if (BuildConfig.DEBUG) "-debug" else "-release"
259260
val clipboardManager = LocalClipboardManager.current
260261

0 commit comments

Comments
 (0)