ci test
[platform/core/csapi/tizenfx.git] / .github / workflows / deploy-packages.yml
1 name: "Deploy Packages"
2
3 on:
4   workflow_dispatch:
5     inputs:
6       target:
7         description: 'Branch to deploy'
8         required: true
9         default: 'master'
10       deploy_to_myget:
11         description: 'Deploy packages to MyGet?'
12         required: true
13         default: true
14       deploy_to_tizen:
15         description: 'Submit changes to Tizen?'
16         required: true
17         default: true
18
19 env:
20   TARGET_BRANCH: ${{ github.event.inputs.target }}
21
22 jobs:
23   deploy:
24     runs-on: ubuntu-latest
25     steps:
26     - uses: actions/checkout@v2
27       with:
28         ref: ${{ env.TARGET_BRANCH }}
29         fetch-depth: 0
30
31     - name: Get Branch Metadata
32       id: metadata
33       uses: TizenAPI/tizenfx-build-actions/branch-metadata@master
34       with:
35         ref: ${{ env.TARGET_BRANCH }}
36
37     - name: Get Version
38       id: version
39       env:
40         VERSION_PREFIX: ${{ steps.metadata.outputs.version-prefix }}
41       run: |
42         VERSION=$VERSION_PREFIX.$((10000+$(git rev-list --count HEAD)))
43         echo VERSION=$VERSION
44         echo "::set-output name=version::$VERSION"
45
46     - name: Build
47       env:
48         VERSION: ${{ steps.version.outputs.version }}
49       run: |
50         ./build.sh full
51         ./build.sh pack $VERSION
52
53     - name: Deploy NuGet packages to MyGet
54       if: github.event.inputs.deploy_to_myget == 'true'
55       env:
56         NUGET_SOURCE: https://tizen.myget.org/F/dotnet-test/api/v2/package
57         APIKEY: ${{ secrets.MYGET_APIKEY }}
58       run: |
59         dotnet nuget push Artifacts/*.nupkg -k $APIKEY -s $NUGET_SOURCE -t 3000
60
61     - name: Setup SSH private keys
62       uses: webfactory/ssh-agent@v0.5.2
63       with:
64         ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
65
66     - name: Submit changes to Tizen
67       if: github.event.inputs.deploy_to_tizen == 'true'
68       env:
69         VERSION: ${{ steps.version.outputs.version }}
70         GERRIT_BRANCH: ${{ steps.metadata.outputs.tizen-branch }}
71         GERRIT_URL: ssh://dotnetbuild@review.tizen.org:29418/platform/core/csapi/tizenfx
72       run: |
73         git config --global user.name "TizenAPI-Bot"
74         git config --global user.email "tizenapi@samsung.com"
75         git config core.sshCommand "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
76         git remote add gerrit $GERRIT_URL
77         git fetch gerrit $GERRIT_BRANCH
78         git checkout -t gerrit/$GERRIT_BRANCH
79         git merge --no-edit -s recursive -X theirs origin/$TARGET_BRANCH
80         ./packaging/makespec.sh -r $VERSION -n $VERSION -i $VERSION
81         git add packaging/
82         if [ $(git diff --cached --numstat | wc -l) -eq 0 ]; then
83           echo "## no changes to sync"
84           exit 0
85         fi
86         SUBMIT_TAG=submit/$GERRIT_BRANCH/$(date '+%Y%m%d.%H%M%S')
87         echo SUBMIT_TAG=$SUBMIT_TAG
88         git commit -m "Release $VERSION"
89         git tag -m "Release $VERSION" $SUBMIT_TAG
90         echo git push -f gerrit HEAD:$GERRIT_BRANCH
91         echo git push gerrit refs/tags/$SUBMIT_TAG