Skip to content

Commit 28aef22

Browse files
committed
Github actions update
1 parent 8de0312 commit 28aef22

File tree

1 file changed

+51
-28
lines changed

1 file changed

+51
-28
lines changed

.github/workflows/gradle.yml

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,59 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
7-
8-
name: Build
1+
name: Build and Release
92
on:
103
push:
11-
branches: [ master ]
12-
pull_request:
13-
branches: [ master ]
4+
tags: [ '*' ] # Запуск при создании тега
145

156
jobs:
167
build:
17-
188
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up JDK 11
12+
uses: actions/setup-java@v2
13+
with:
14+
java-version: '11'
15+
distribution: 'temurin'
16+
- name: Build with Gradle
17+
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
18+
with:
19+
arguments: build
20+
- name: Upload Build Artifact
21+
uses: actions/upload-artifact@v2
22+
with:
23+
name: musicbox
24+
path: |
25+
build/libs/MusicBox*-all.jar
1926
27+
release:
28+
needs: build
29+
runs-on: ubuntu-latest
2030
steps:
21-
- uses: actions/checkout@v2
22-
- name: Set up JDK 11
23-
uses: actions/setup-java@v2
24-
with:
25-
java-version: '11'
26-
distribution: 'temurin'
27-
- name: Build with Gradle
28-
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
29-
with:
30-
arguments: build
31-
- name: Upload Build Artifact
32-
uses: actions/upload-artifact@v2
33-
with:
34-
name: musicbox
35-
path: |
36-
build/libs/MusicBox*-all.jar
31+
- name: Checkout code
32+
uses: actions/checkout@v2
33+
- name: Download Build Artifact
34+
uses: actions/download-artifact@v2
35+
with:
36+
name: musicbox
37+
path: build/libs/
38+
- name: Get Artifact Filename
39+
id: get_filename
40+
run: echo "FILENAME=$(basename build/libs/MusicBox*-all.jar)" >> $GITHUB_ENV
41+
- name: Create GitHub Release
42+
id: create_release
43+
uses: actions/create-release@v1
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
with:
47+
tag_name: ${{ github.ref }}
48+
release_name: Release ${{ github.ref }}
49+
draft: false
50+
prerelease: false
51+
- name: Upload Release Asset
52+
uses: actions/upload-release-asset@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
with:
56+
upload_url: ${{ steps.create_release.outputs.upload_url }}
57+
asset_path: build/libs/${{ env.FILENAME }}
58+
asset_name: ${{ env.FILENAME }}
59+
asset_content_type: application/java-archive

0 commit comments

Comments
 (0)