aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/release.yml
blob: 2c5315d9f84ac9593d2284a995c6d188809a3665 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Release google-java-format

on:
  workflow_dispatch:
    inputs:
      version:
        description: "version number for this release."
        required: true

jobs:
  build-maven-jars:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Setup Signing Key
        run: |
          gpg-agent --daemon --default-cache-ttl 7200
          echo -e "${{ secrets.GPG_SIGNING_KEY }}" | gpg --batch --import --no-tty
          echo "hello world" > temp.txt
          gpg --detach-sig --yes -v --output=/dev/null --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" temp.txt
          rm temp.txt
          gpg --list-secret-keys --keyid-format LONG
          
      - name: Checkout
        uses: actions/checkout@v2.4.0

      - name: Set up JDK
        uses: actions/setup-java@v2.5.0
        with:
          java-version: 17
          distribution: 'zulu'
          cache: 'maven'
     
      - name: Bump Version Number
        run: |
          mvn --no-transfer-progress versions:set versions:commit -DnewVersion="${{ github.event.inputs.version }}"
          mvn tycho-versions:update-eclipse-metadata -pl eclipse_plugin
          git ls-files | grep 'pom.xml$' | xargs git add
          git config --global user.email "${{ github.actor }}@users.noreply.github.com"
          git config --global user.name "${{ github.actor }}"
          git commit -m "Release google-java-format ${{ github.event.inputs.version }}"
          git tag "v${{ github.event.inputs.version }}"
          echo "TARGET_COMMITISH=$(git rev-parse HEAD)" >> $GITHUB_ENV
          git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/google/google-java-format.git
          git push origin "v${{ github.event.inputs.version }}"
          
      - name: Build Jars
        run: mvn --no-transfer-progress clean verify gpg:sign -DskipTests=true -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}"

      - name: Add Jars to Release Entry
        uses: softprops/action-gh-release@v0.1.14
        with:
          draft: true
          name: ${{ github.event.input.version }} 
          tag_name: "v${{ github.event.inputs.version }}"
          target_commitish: ${{ env.TARGET_COMMITISH }}
          files: |
            core/target/google-java-format-*.jar
            eclipse_plugin/target/google-java-format-eclipse-plugin-*.jar