Revert "Update nightly-release.yml (#5758)" (#5761)
[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: Deploy NuGet packages to Github Packages Registry
75       if: github.event.inputs.deploy_to_gpr == 'true'
76       env:
77         PACKAGES_SOURCE: https://nuget.pkg.github.com/Samsung/index.json
78         APIKEY: ${{ secrets.GITHUB_TOKEN }}
79       run: |
80         dotnet nuget push Artifacts/*.nupkg -k $APIKEY -s $PACKAGES_SOURCE -t 3000
81
82     - name: Deploy NuGet packages to MyGet
83       if: github.event.inputs.deploy_to_myget == 'true'
84       env:
85         NUGET_SOURCE: https://tizen.myget.org/F/dotnet/api/v2/package
86         APIKEY: ${{ secrets.MYGET_APIKEY }}
87       run: |
88         dotnet nuget push Artifacts/*.nupkg -k $APIKEY -s $NUGET_SOURCE -t 3000
89
90     - name: Setup SSH private keys
91       uses: webfactory/ssh-agent@v0.7.0
92       with:
93         ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
94
95     - name: Submit changes to Tizen
96       if: github.event.inputs.deploy_to_tizen == 'true'
97       env:
98         VERSION: ${{ steps.version.outputs.version }}
99         GERRIT_BRANCH: ${{ steps.metadata.outputs.tizen-branch }}
100         GERRIT_URL: ssh://dotnetbuild@review.tizen.org:29418/platform/core/csapi/tizenfx
101       run: |
102         if [ -z "$GERRIT_BRANCH" ]; then
103           echo "## no specified tizen branch"
104           exit 0
105         fi
106         git remote add gerrit $GERRIT_URL
107         git fetch gerrit $GERRIT_BRANCH
108         git checkout -t gerrit/$GERRIT_BRANCH
109         git merge --no-edit -s recursive -X theirs origin/$TARGET_BRANCH
110         ./packaging/makespec.sh -r $VERSION -n $VERSION -i $VERSION
111         git add packaging/
112         if [ $(git diff --cached --numstat | wc -l) -eq 0 ]; then
113           echo "## no changes to sync"
114           exit 0
115         fi
116         SUBMIT_TAG=submit/$GERRIT_BRANCH/$(date '+%Y%m%d.%H%M%S')
117         echo SUBMIT_TAG=$SUBMIT_TAG
118         git commit -m "Release $VERSION"
119         git tag -m "Release $VERSION" $SUBMIT_TAG
120         git push -f gerrit HEAD:$GERRIT_BRANCH
121         git push gerrit refs/tags/$SUBMIT_TAG
122         echo "::notice title=Submit Request TAG::$SUBMIT_TAG"