microsoft/gctoolkit
Publicmirrored fromhttps://github.com/microsoft/gctoolkitAvailable
.github/workflows/release_to_github.yml
60lines · modecode
| 1 | name: Release to GitHub |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | |
| 6 | jobs: |
| 7 | release: |
| 8 | permissions: |
| 9 | contents: write |
| 10 | |
| 11 | runs-on: ubuntu-latest |
| 12 | |
| 13 | steps: |
| 14 | - name: Checkout project |
| 15 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 16 | with: |
| 17 | ref: main |
| 18 | fetch-depth: 0 |
| 19 | |
| 20 | - name: Cache Maven |
| 21 | uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1 |
| 22 | with: |
| 23 | path: ~/.m2/repository |
| 24 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 25 | restore-keys: ${{ runner.os }}-m2 |
| 26 | |
| 27 | - name: Setup Java JDK |
| 28 | uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 |
| 29 | with: |
| 30 | java-version: '11' |
| 31 | distribution: 'microsoft' |
| 32 | |
| 33 | - name: Version |
| 34 | id: version |
| 35 | run: | |
| 36 | release_tag=$( ./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout ) |
| 37 | release_tag=${release_tag%-*} |
| 38 | echo "release_tag=gctoolkit-${release_tag}" >> "$GITHUB_ENV" |
| 39 | |
| 40 | previous_tag=$( git tag --sort=-taggerdate --list 'gctoolkit-*' | head -n1 ) |
| 41 | echo "previous_tag=${previous_tag}" >> "$GITHUB_ENV" |
| 42 | |
| 43 | - name: Release Prepare |
| 44 | run: | |
| 45 | ./mvnw -B -Prelease release:clean release:prepare \ |
| 46 | -Drepository.url=https://${{ github.actor }}:${{ secrets.RELEASE_TOKEN }}@github.com/${{ github.repository }}.git |
| 47 | env: |
| 48 | GIT_AUTHOR_NAME: 'Git' |
| 49 | GIT_AUTHOR_EMAIL: 'noreply@github.com' |
| 50 | GIT_COMMITTER_NAME: 'Git' |
| 51 | GIT_COMMITTER_EMAIL: 'noreply@github.com' |
| 52 | |
| 53 | - name: Release to GitHub |
| 54 | run: | |
| 55 | git checkout "$release_tag" |
| 56 | ./mvnw -B -pl :gctoolkit -Pjreleaser jreleaser:release \ |
| 57 | -Djreleaser.previous.tag.name="$previous_tag" \ |
| 58 | -Djreleaser.tag.name="$release_tag" |
| 59 | env: |
| 60 | JRELEASER_GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |
| 61 | |