microsoft/gctoolkit
Publicmirrored from https://github.com/microsoft/gctoolkitAvailable
.github/workflows/release_to_github.yml
60lines · modeblame
d7040222David Grieve1 years ago | 1 | name: Release to GitHub |
| 2 | | |
| 3 | on: | |
| 4 | workflow_dispatch: | |
| 5 | | |
| 6 | jobs: | |
| 7 | release: | |
c577cf20David Grieve1 years ago | 8 | permissions: |
| 9 | contents: write | |
| 10 | | |
d7040222David Grieve1 years ago | 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@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
| 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@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 | |
| 29 | with: | |
| 30 | java-version: '11' | |
| 31 | distribution: 'microsoft' | |
| 32 | | |
| 33 | - name: Version | |
| 34 | id: version | |
| 35 | run: | | |
b0afe430David Grieve1 years ago | 36 | release_tag=$( ./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout ) |
05a93f83David Grieve1 years ago | 37 | release_tag=${release_tag%-*} |
17a482f3David Grieve1 years ago | 38 | echo "release_tag=gctoolkit-${release_tag}" >> "$GITHUB_ENV" |
d7040222David Grieve1 years ago | 39 | |
05a93f83David Grieve1 years ago | 40 | previous_tag=$( git tag --sort=-taggerdate --list 'gctoolkit-*' | head -n1 ) |
637824b3David Grieve1 years ago | 41 | echo "previous_tag=${previous_tag}" >> "$GITHUB_ENV" |
d7040222David Grieve1 years ago | 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: | | |
05a93f83David Grieve1 years ago | 55 | git checkout "$release_tag" |
d7040222David Grieve1 years ago | 56 | ./mvnw -B -pl :gctoolkit -Pjreleaser jreleaser:release \ |
637824b3David Grieve1 years ago | 57 | -Djreleaser.previous.tag.name="$previous_tag" \ |
05a93f83David Grieve1 years ago | 58 | -Djreleaser.tag.name="$release_tag" |
d7040222David Grieve1 years ago | 59 | env: |
0a0152c5David Grieve1 years ago | 60 | JRELEASER_GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |