3ab8de9d3c7cc5e8cc6ae49c7ca834d7e7cf652a
[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_gpr:
11         description: 'Deploy packages to Github Packages Registry?'
12         required: true
13         default: true
14       deploy_to_myget:
15         description: 'Deploy packages to MyGet?'
16         required: true
17         default: true
18       deploy_to_tizen:
19         description: 'Submit changes to Tizen?'
20         required: true
21         default: true
22
23 env:
24   TARGET_BRANCH: ${{ github.event.inputs.target }}
25
26 jobs:
27   deploy:
28     runs-on: ubuntu-20.04
29     steps:
30     - uses: actions/checkout@v3
31       with:
32         ref: ${{ env.TARGET_BRANCH }}
33         fetch-depth: 0
34     
35     - uses: actions/setup-dotnet@v3
36       with:
37         dotnet-version: '6.0.102'
38
39     - name: Git Config
40       run: |
41         git config --global user.name "TizenAPI-Bot"
42         git config --global user.email "tizenapi@samsung.com"
43         git config core.sshCommand "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
44
45     - name: Get Branch Metadata
46       id: metadata
47       uses: TizenAPI/tizenfx-build-actions/branch-metadata@master
48       with:
49         ref: ${{ env.TARGET_BRANCH }}
50
51     - name: Get Version
52       id: version
53       env:
54         VERSION_PREFIX: ${{ steps.metadata.outputs.version-prefix }}
55       run: |
56         VERSION=$VERSION_PREFIX.$((10000+$(git rev-list --count HEAD)))
57         echo VERSION=$VERSION
58         echo "version=$VERSION" >> $GITHUB_OUTPUT
59
60     - name: Build
61       env:
62         VERSION: ${{ steps.version.outputs.version }}
63       run: |
64         ./build.sh full
65         ./build.sh pack $VERSION
66
67     - name: Tag Version
68       env:
69         VERSION: ${{ steps.version.outputs.version }}
70       run: |
71         git tag -fa "v$VERSION" -m "Release $VERSION"
72         git push -f --tags origin refs/tags/"v$VERSION"
73
74     - name: Install Github Package Registry Tool
75       if: github.event.inputs.deploy_to_gpr == 'true'
76       run: dotnet tool install --global --no-cache gpr
77
78     - name: Deploy NuGet packages to Github Packages Registry
79       if: github.event.inputs.deploy_to_gpr == 'true'
80       run: |
81         gpr push --api-key ${{ secrets.TIZENAPI_GITHUB_TOKEN }} \
82                  --repository ${{ github.repository }} \
83                  --retries 3 Artifacts/*.nupkg
84
85     - name: Deploy NuGet packages to MyGet
86       if: github.event.inputs.deploy_to_myget == 'true'
87       env:
88         NUGET_SOURCE: https://tizen.myget.org/F/dotnet/api/v2/package
89         APIKEY: ${{ secrets.MYGET_APIKEY }}
90       run: |
91         dotnet nuget push Artifacts/*.nupkg -k $APIKEY -s $NUGET_SOURCE -t 3000
92
93     - name: Setup SSH private keys
94       uses: webfactory/ssh-agent@v0.7.0
95       with:
96         ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
97
98     - name: Submit changes to Tizen
99       if: github.event.inputs.deploy_to_tizen == 'true'
100       env:
101         VERSION: ${{ steps.version.outputs.version }}
102         GERRIT_BRANCH: ${{ steps.metadata.outputs.tizen-branch }}
103         GERRIT_URL: ssh://dotnetbuild@review.tizen.org:29418/platform/core/csapi/tizenfx
104       run: |
105         if [ -z "$GERRIT_BRANCH" ]; then
106           echo "## no specified tizen branch"
107           exit 0
108         fi
109         git remote add gerrit $GERRIT_URL
110         git fetch gerrit $GERRIT_BRANCH
111         git checkout -t gerrit/$GERRIT_BRANCH
112         git merge --no-edit -s recursive -X theirs origin/$TARGET_BRANCH
113         ./packaging/makespec.sh -r $VERSION -n $VERSION -i $VERSION
114         git add packaging/
115         if [ $(git diff --cached --numstat | wc -l) -eq 0 ]; then
116           echo "## no changes to sync"
117           exit 0
118         fi
119         SUBMIT_TAG=submit/$GERRIT_BRANCH/$(date '+%Y%m%d.%H%M%S')
120         echo SUBMIT_TAG=$SUBMIT_TAG
121         git commit -m "Release $VERSION"
122         git tag -m "Release $VERSION" $SUBMIT_TAG
123         git push -f gerrit HEAD:$GERRIT_BRANCH
124         git push gerrit refs/tags/$SUBMIT_TAG
125         echo "::notice title=Submit Request TAG::$SUBMIT_TAG"