summaryrefslogtreecommitdiffstats
path: root/.github/workflows/gitblit-release.yml
blob: 24cc4150948a2e5676299a6a26ffacd86338216b (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Release in gitblit/gitblit repo

on:
  push:
    tags:
      - 'r[0-9]+.[0-9]+.[0-9]+*'

jobs:

  build_and_test:
    name: Build and test
    runs-on: ubuntu-latest
    if: github.repository == 'fzs/gitblit'

    steps:
      - name: Checkout
        uses: actions/checkout@v1
        with:
          submodules: true

      - name: Setup Java 7
        uses: actions/setup-java@v1
        with:
          java-version: 7

      - name: Report Java version
        run: |
          java -version
          javac -version

      - name: Setup Moxie
        run: |
          wget http://gitblit.github.io/moxie/maven/com/gitblit/moxie/moxie+ant/0.9.4/moxie+ant-0.9.4.tar.gz
          tar -xzf moxie+ant-0.9.4.tar.gz
          moxie-0.9.4/bin/moxie -version

      - name: Build with Moxie
        run:  moxie-0.9.4/bin/moxie test



  build_release:
    name: Build and deploy release
    runs-on: ubuntu-latest
    needs: build_and_test
    env:
      GH_ORG: gitblit
      moxie: moxie-0.9.4/bin/moxie
      versinfo: ../verinf.sh

    steps:
      - name: Setup Java 7
        uses: actions/setup-java@v1
        with:
          java-version: 7

      - name: Report Java version
        run: |
          java -version
          javac -version



      - name: Set up Git properties
        run: |
          set -x 
          git config --global user.name ${{ github.event.pusher.name }}
          git config --global user.email ${{ github.event.pusher.email }}

      - name: Checkout gitblit master for reference
        uses: actions/checkout@v2
        with:
          path: gitblit-ref
          ref: master
          fetch-depth: 2
      - name: Fetch all branches in reference
        run: |
          cd gitblit-ref
          git fetch --no-tags --prune --depth=2 origin +refs/heads/*:refs/remotes/origin/*

      - name: Checkout gitblit master from gitblit
        uses: actions/checkout@v2
        with:
          path: gitblit
          repository: ${{ env.GH_ORG }}/gitblit
          ref: master
          token: ${{ secrets.GITBLIT_RELEASE_PAT }}
          fetch-depth: 2
      - name: Fetch all branches from gitblit
        run: |
          cd gitblit
          git fetch --no-tags --prune --depth=2 origin +refs/heads/*:refs/remotes/origin/*
      - name: Checkout submodules in gitblit
        shell: bash
        run: |
          cd gitblit
          git submodule sync --recursive
          git submodule update --init --force --recursive

      - name: Check if gitblit repo is on the same branch and commit as my reference
        run: |
          cd gitblit-ref
          refC=$(git rev-parse HEAD)
          refB=$(git symbolic-ref -q --short HEAD)
          cd ../gitblit
          gbC=$(git rev-parse HEAD)
          gbB=$(git symbolic-ref -q --short HEAD)
          echo "$refB - $gbB"
          if [ "$refB" != "$gbB" ] ; then echo "Not the same branch in refrence and gitblit repo!" ; exit 1 ; fi
          echo "refC: $refC"
          echo "gbC:  $gbC"
          if [ "$refC" != "$gbC" ] ; then echo "Different commits in refrence and gitblit repo" ; exit 2 ; fi
        continue-on-error: false


      - name: Checkout gitblit maven repository
        uses: actions/checkout@v2
        with:
          path: gitblit-maven
          repository: ${{ env.GH_ORG }}/gitblit-maven
          ref: gh-pages
          token: ${{ secrets.GITBLIT_RELEASE_PAT }}


      - name: Setup Moxie
        run: |
          wget http://gitblit.github.io/moxie/maven/com/gitblit/moxie/moxie+ant/0.9.4/moxie+ant-0.9.4.tar.gz
          tar -xzf moxie+ant-0.9.4.tar.gz
          $moxie -version



      - name: Create release version
        working-directory: gitblit
        run:  |
          ../$moxie -DversionInfo=${versinfo} tagRelease
          cat ${versinfo}
          . ${versinfo}
          echo "Release version $GB_RELEASE_VERSION with tag $GB_RELEASE_TAG"



      - name: Build release artifacts
        run: |
          cd gitblit
          ../$moxie clean buildAll buildMavenArtifacts

      - name: Commit Maven artifacts
        working-directory: gitblit-maven
        run: |
          . ${versinfo}
          git diff -R -U2 -- artifacts.json | awk 'BEGIN{FS="\n" ; RS="@"; ORS="@"} { for (i=1;i<=NF;i++){if ($i ~ /description/) {print "Skip block";next;}} print $0 }' | sed -e 's/^@@ .* @@Skip block//' -e '/^@$/ d' | patch -p1 artifacts.json
          git diff -- artifacts.json
          git add .
          git commit -m "Release $GB_RELEASE_VERSION artifacts"
          
      - name: Update website
        working-directory: gitblit
        run: |
          echo "Create local gh-pages branch"
          git branch --force --track gh-pages refs/remotes/origin/gh-pages
          ../$moxie updateSite



      - name: Create release and upload artifacts
        env:
          GITHUB_TOKEN: ${{ secrets.GITBLIT_RELEASE_PAT }}
        working-directory: gitblit
        run: ../$moxie releaseBinaries

      - name: Push Maven artifacts to repository
        working-directory: gitblit-maven
        run: git push origin gh-pages

      - name: Push updated gh-pages and release tag
        working-directory: gitblit
        run: |
          . ${versinfo}
          git status
          git push origin gh-pages ${GB_RELEASE_TAG}

      - name: Publish GitHub release
        env:
          GITHUB_TOKEN: ${{ secrets.GITBLIT_RELEASE_PAT }}
        working-directory: gitblit
        run: ../$moxie publishRelease



      - name: Update build identifier and version for next development cycle
        working-directory: gitblit
        run: |
          git checkout master
          ../$moxie nextPointReleaseCycle
          git push origin