Added Git tag creation and updated download artifact step in publish.… #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish for JitPack | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
release: | |
types: [published] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: zulu | |
java-version: 17 | |
cache: gradle | |
- name: Grant execute permissions to Gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew clean build --no-daemon | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Build Artifacts | |
path: '**/build/libs/*.jar' | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Create Git Tag | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git tag v1.0.${{ github.run_number }} | |
git push origin v1.0.${{ github.run_number }} | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: Build Artifacts | |
- name: Attach Artifacts to Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: '**/*.jar' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag_name: v1.0.${{ github.run_number }} | |
release_name: "Release v1.0.${{ github.run_number }}" | |
body: "Automatic release by GitHub Actions" |