3882c28a85027a19e5c214c2e085d507da88c418
[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: Git Config
32       run: |
33         git config --global user.name "TizenAPI-Bot"
34         git config --global user.email "tizenapi@samsung.com"
35         git config core.sshCommand "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
36
37     - name: Get Branch Metadata
38       id: metadata
39       uses: TizenAPI/tizenfx-build-actions/branch-metadata@master
40       with:
41         ref: ${{ env.TARGET_BRANCH }}
42
43     - name: Get Version
44       id: version
45       env:
46         VERSION_PREFIX: ${{ steps.metadata.outputs.version-prefix }}
47       run: |
48         VERSION=$VERSION_PREFIX.$((10000+$(git rev-list --count HEAD)))
49         echo VERSION=$VERSION
50         echo "::set-output name=version::$VERSION"
51
52     - name: Build
53       env:
54         VERSION: ${{ steps.version.outputs.version }}
55       run: |
56         ./build.sh full
57         ./build.sh pack $VERSION
58
59     - name: Tag Version
60       env:
61         VERSION: ${{ steps.version.outputs.version }}
62       run: |
63         git tag -fa "v$VERSION" -m "Release $VERSION"
64         git push -f --tags origin refs/tags/"v$VERSION"
65
66     - name: Deploy NuGet packages to MyGet
67       if: github.event.inputs.deploy_to_myget == 'true'
68       env:
69         NUGET_SOURCE: https://tizen.myget.org/F/dotnet/api/v2/package
70         APIKEY: ${{ secrets.MYGET_APIKEY }}
71       run: |
72         dotnet nuget push Artifacts/*.nupkg -k $APIKEY -s $NUGET_SOURCE -t 3000
73
74     - name: Setup SSH private keys
75       uses: webfactory/ssh-agent@v0.5.2
76       with:
77         ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
78
79     - name: Submit changes to Tizen
80       if: github.event.inputs.deploy_to_tizen == 'true'
81       env:
82         VERSION: ${{ steps.version.outputs.version }}
83         GERRIT_BRANCH: ${{ steps.metadata.outputs.tizen-branch }}
84         GERRIT_URL: ssh://dotnetbuild@review.tizen.org:29418/platform/core/csapi/tizenfx
85       run: |
86         git remote add gerrit $GERRIT_URL
87         git fetch gerrit $GERRIT_BRANCH
88         git checkout -t gerrit/$GERRIT_BRANCH
89         git merge --no-edit -s recursive -X theirs origin/$TARGET_BRANCH
90         ./packaging/makespec.sh -r $VERSION -n $VERSION -i $VERSION
91         git add packaging/
92         if [ $(git diff --cached --numstat | wc -l) -eq 0 ]; then
93           echo "## no changes to sync"
94           exit 0
95         fi
96         SUBMIT_TAG=submit/$GERRIT_BRANCH/$(date '+%Y%m%d.%H%M%S')
97         echo SUBMIT_TAG=$SUBMIT_TAG
98         git commit -m "Release $VERSION"
99         git tag -m "Release $VERSION" $SUBMIT_TAG
100         git push -f gerrit HEAD:$GERRIT_BRANCH
101         git push gerrit refs/tags/$SUBMIT_TAG
102         echo "::notice title=Submit Request TAG::$SUBMIT_TAG"