Welcome to mirror list, hosted at ThFree Co, Russian Federation.

release.yml « workflows « .github - github.com/nextcloud/maps.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 74269057755eda2556d0dc3cfe32afff9fc7d913 (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
on:
  push:
    branches: [release]

name: Publish release

jobs:
  build:
    name: Build, upload and release in the appstore
    environment: release
    env:
      APP_ID: maps
    runs-on: ubuntu-latest
    steps:
      - name: Use Node 14
        uses: actions/setup-node@v1
        with:
          node-version: 14

      - name: Set up npm
        run: npm i -g npm

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.4'
          extensions: mbstring, intl, sqlite3
          ini-values: post_max_size=256M, max_execution_time=180
          coverage: xdebug
          tools: php-cs-fixer, phpunit

      - name: Checkout code
        uses: actions/checkout@v2

      - name: Get current tag
        id: tag
        run: |
          git fetch --tags --force
          tag=$(git tag -l --points-at HEAD)
          vtag=$(echo $tag | grep "^v[0-9]\+\.[0-9]\+\.[0-9]\+" || echo "")
          echo "##[set-output name=currenttag;]$vtag"

      - name: Build project
        if: ${{ startsWith( steps.tag.outputs.currenttag , 'v' ) }}
        id: build_release
        run: |
          echo "##[set-output name=app_id;]$APP_ID"
          echo "###### copy app certificate"
          mkdir -p ~/.nextcloud/certificates
          echo "$APP_CRT" > ~/.nextcloud/certificates/${APP_ID}.crt
          echo "$APP_KEY" > ~/.nextcloud/certificates/${APP_ID}.key
          echo "###### install dependencies"
          export DEBIAN_FRONTEND=noninteractive
          sudo apt update -y
          #sudo apt upgrade -y
          sudo apt install make openssl -y
          echo "###### installing nextcloud"
          mkdir ~/html
          git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b master ~/html/nextcloud
          sed -i $'s|if (substr($fullPath, 0, strlen($root) + 1) === $root . \'/\')|if (is_string($root) and substr($fullPath, 0, strlen($root) + 1) === $root . \'/\')|g' ~/html/nextcloud/lib/autoloader.php
          cp -r $GITHUB_WORKSPACE ~/html/nextcloud/apps/${APP_ID}
          php ~/html/nextcloud/occ maintenance:install --database "sqlite" --admin-user "admin" --admin-pass "password"
          cd ~/html/nextcloud/apps/${APP_ID}
          echo "###### make"
          webserveruser=runner occ_dir=~/html/nextcloud make > /dev/null
          php ~/html/nextcloud/occ app:enable ${APP_ID}
          php ~/html/nextcloud/occ maintenance:mode --off
          echo "###### make appstore"
          tag=${{ steps.tag.outputs.currenttag }}
          version=${tag/v/}
          webserveruser=runner occ_dir=~/html/nextcloud version=$version make appstore
          echo "##[set-output name=version;]$version"
        env:
          APP_CRT: ${{ secrets.APP_CRT }}
          APP_KEY: ${{ secrets.APP_KEY }}

      - name: Create Release
        if: ${{ startsWith( steps.tag.outputs.currenttag , 'v' ) }}
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ steps.tag.outputs.currenttag }}
          release_name: ${{ steps.tag.outputs.currenttag }}
          draft: false
          prerelease: false

      - name: Upload Release Asset
        if: ${{ startsWith( steps.tag.outputs.currenttag , 'v' ) }}
        id: upload-release-asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: /tmp/build/${{ steps.build_release.outputs.app_id }}-${{ steps.build_release.outputs.version }}.tar.gz
          asset_name: ${{ steps.build_release.outputs.app_id }}-${{ steps.build_release.outputs.version }}.tar.gz
          asset_content_type: application/gzip

      - name: Publish normal release to appstore
        if: ${{ startsWith( steps.tag.outputs.currenttag , 'v' ) && !endsWith( steps.tag.outputs.currenttag , 'nightly' ) }}
        id: publish
        run: |
          SIGNATURE=$(cat /tmp/build/sign.txt | tr -d '\n')
          VERSION=${{ steps.build_release.outputs.version }}
          DOWNLOAD_URL=https://github.com/${{ github.repository }}/releases/download/v${VERSION}/${APP_ID}-${VERSION}.tar.gz
          curl -X POST -H "Authorization: Token $APPSTORE_TOKEN" https://apps.nextcloud.com/api/v1/apps/releases -H "Content-Type: application/json" -d '{"download":"'${DOWNLOAD_URL}'", "signature": "'${SIGNATURE}'"}'
        env:
          APPSTORE_TOKEN: ${{ secrets.APPSTORE_TOKEN }}

      - name: Publish nightly release to appstore
        if: ${{ startsWith( steps.tag.outputs.currenttag , 'v' ) && endsWith( steps.tag.outputs.currenttag , 'nightly' ) }}
        id: nightly
        run: |
          SIGNATURE=$(cat /tmp/build/sign.txt | tr -d '\n')
          VERSION=${{ steps.build_release.outputs.version }}
          DOWNLOAD_URL=https://github.com/${{ github.repository }}/releases/download/v${VERSION}/${APP_ID}-${VERSION}.tar.gz
          curl -X POST -H "Authorization: Token $APPSTORE_TOKEN" https://apps.nextcloud.com/api/v1/apps/releases -H "Content-Type: application/json" -d '{"download":"'${DOWNLOAD_URL}'", "signature": "'${SIGNATURE}'", "nightly": true}'
        env:
          APPSTORE_TOKEN: ${{ secrets.APPSTORE_TOKEN }}