Skip to content

Commit 17b6697

Browse files
committed
Github actions update
1 parent 8de0312 commit 17b6697

File tree

1 file changed

+53
-25
lines changed

1 file changed

+53
-25
lines changed

.github/workflows/gradle.yml

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,64 @@
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:
114
branches: [ master ]
5+
tags: [ '*' ] # Запуск при создании тега
126
pull_request:
137
branches: [ master ]
148

159
jobs:
1610
build:
17-
1811
runs-on: ubuntu-latest
1912

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

0 commit comments

Comments
 (0)