Skip to content

Commit b214fb6

Browse files
committed
ci: update main.yml
1 parent 6a906b4 commit b214fb6

File tree

4 files changed

+80
-46
lines changed

4 files changed

+80
-46
lines changed

.github/workflows/main.yml

+66-45
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,73 @@
55
#
66
# GitHub Actions reference: https://help.github.com/en/actions
77
#
8-
on:
9-
push:
10-
branches:
11-
- main
8+
on:
9+
push:
10+
branches:
11+
- main
1212

13-
jobs:
14-
main:
15-
runs-on: ubuntu-latest
16-
steps:
17-
# Check out current repository
18-
- name: Fetch Sources
19-
uses: actions/checkout@v3
13+
jobs:
14+
publish_snapshot:
15+
name: Publish Snapshot
16+
runs-on: ubuntu-latest
17+
steps:
18+
# Check out current repository
19+
- name: Fetch Sources
20+
uses: actions/checkout@v3
2021

21-
# Set up Java environment for the next steps
22-
- name: Setup Java
23-
uses: actions/setup-java@v3
24-
with:
25-
distribution: zulu
26-
java-version: 17
22+
# Set up Java environment for the next steps
23+
- name: Setup Java
24+
uses: actions/setup-java@v3
25+
with:
26+
distribution: zulu
27+
java-version: 17
28+
- name: Publish Snapshot
29+
run: |
30+
chmod +x ./publish_snapshot.sh
31+
./publish_snapshot.sh ${{secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME}} ${{secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD}}
2732
28-
# Set environment variables
29-
- name: Export Properties
30-
id: properties
31-
shell: bash
32-
run: |
33-
PROPERTIES="$(./gradlew properties --console=plain -q)"
34-
VERSION="$(echo "$PROPERTIES" | grep "^VERSION_NAME:" | cut -f2- -d ' ')"
35-
CHANGELOG="$(./get_changelog.sh)"
36-
echo "version=$VERSION" >> $GITHUB_OUTPUT
37-
echo "changelog=$CHANGELOG" >> $GITHUB_OUTPUT
38-
39-
# Remove old release drafts by using the curl request for the available releases with a draft flag
40-
- name: Remove Old Release Drafts
41-
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
run: |
44-
gh api repos/{owner}/{repo}/releases \
45-
--jq '.[] | select(.draft == true) | .id' \
46-
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
33+
update_draft_release:
34+
name: Create or Update Draft Release
35+
runs-on: ubuntu-latest
36+
steps:
37+
# Check out current repository
38+
- name: Fetch Sources
39+
uses: actions/checkout@v3
4740

48-
# Create a new release draft which is not publicly visible and requires manual acceptance
49-
- name: Create Release Draft
50-
env:
51-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52-
run: |
53-
gh release create v${{ steps.properties.outputs.version }} \
54-
--draft \
55-
--title "v${{ steps.properties.outputs.version }}" \
56-
--notes "${{ steps.properties.outputs.changelog }}" \
41+
# Set up Java environment for the next steps
42+
- name: Setup Java
43+
uses: actions/setup-java@v3
44+
with:
45+
distribution: zulu
46+
java-version: 17
47+
48+
# Set environment variables
49+
- name: Export Properties
50+
id: properties
51+
shell: bash
52+
run: |
53+
PROPERTIES="$(./gradlew properties --console=plain -q)"
54+
VERSION="$(echo "$PROPERTIES" | grep "^VERSION_NAME:" | cut -f2- -d ' ')"
55+
chmod +x ./get_changelog.sh
56+
CHANGELOG="$(./get_changelog.sh $VERSION)"
57+
echo "version=$VERSION" >> $GITHUB_OUTPUT
58+
echo "changelog=$(echo "$CHANGELOG" | base64 )" >> $GITHUB_OUTPUT
59+
60+
# Remove old release drafts by using the curl request for the available releases with a draft flag
61+
- name: Remove Old Release Drafts
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
run: |
65+
gh api repos/{owner}/{repo}/releases \
66+
--jq '.[] | select(.draft == true) | .id' \
67+
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
68+
69+
# Create a new release draft which is not publicly visible and requires manual acceptance
70+
- name: Create Release Draft
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
run: |
74+
gh release create v${{ steps.properties.outputs.version }} \
75+
--draft \
76+
--title "v${{ steps.properties.outputs.version }}" \
77+
--notes "$(echo "${{ steps.properties.outputs.changelog }}" | base64 --decode)"

get_changelog.sh

100644100755
File mode changed.

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ android.nonTransitiveRClass=true
2424

2525
# POM values
2626
GROUP=io.monstarlab.mosaic
27-
VERSION_NAME=0.0.1-SNAPSHOT
27+
VERSION_NAME=0.0.1
2828

2929
POM_NAME=Mosaic
3030
POM_DESCRIPTION=A collection of UI components.

publish_snapshot.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Check if the file exists
2+
MAVEN_CENTRAL_USERNAME=$1
3+
MAVEN_CENTRAL_PASSWORD=$2
4+
if [ ! -f "gradle.properties" ]; then
5+
echo "gradle.properties does not exist."
6+
exit 1
7+
fi
8+
# Append -SNAPSHOT to the VERSION_NAME
9+
sed -i -e '/VERSION_NAME/s/$/-SNAPSHOT/' "gradle.properties"
10+
11+
./gradlew publishAllPublicationsToMavenCentralRepository \
12+
-PmavenCentralUsername="$MAVEN_CENTRAL_USERNAME" \
13+
-PmavenCentralPassword="$MAVEN_CENTRAL_PASSWORD"

0 commit comments

Comments
 (0)