-
Notifications
You must be signed in to change notification settings - Fork 8
90 lines (80 loc) · 4 KB
/
on-push-to-release-branch.yaml
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
name: On push to release
on:
push:
branches: [release]
jobs:
release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.release.outputs.release }}
steps:
- uses: actions/checkout@v3
- name: Set release
id: semrel
uses: go-semantic-release/action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-initial-development-versions: false
force-bump-patch-version: true
# For whatever reason, this silly tool won't let you do releases from branches
# other than the default branch unless you pass this flag, which doesn't seem
# to actually have anything to do with CI:
# https://github.com/go-semantic-release/semantic-release/blob/master/cmd/semantic-release/main.go#L173-L194
# https://github.com/go-semantic-release/condition-github/blob/4c8af3fc516151423fff2f77eb08bf7082570676/pkg/condition/github.go#L42-L44
custom-arguments: "--no-ci"
- name: Output release
id: release
run: echo "::set-output name=release::${{ steps.semrel.outputs.version }}"
publish:
runs-on: ubuntu-latest
needs: release
steps:
- name: Get current time
uses: gerred/actions/current-time@master
id: current-time
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"
- name: Pack and Publish the standard SDK
run: |
set -x
pushd src/Momento.Sdk
VERSION="${{ needs.release.outputs.version }}"
echo "version: ${VERSION}"
dotnet build --configuration Release
dotnet pack -c Release -p:Version=${VERSION}
dotnet nuget push ./bin/Release/Momento.Sdk.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key=${{secrets.NUGET_API_KEY}}
popd
- name: Pack and Publish the web SDK
run: |
set -x
pushd src/Momento.Sdk
VERSION="${{ needs.release.outputs.version }}"
echo "version: ${VERSION}"
dotnet build -p:DefineConstants=USE_GRPC_WEB --configuration Release
dotnet pack -p:DefineConstants=USE_GRPC_WEB -c Release -p:Version=${VERSION}
dotnet nuget push ./bin/Release/Momento.Sdk.Web.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key=${{secrets.NUGET_API_KEY}}
popd
- name: Build for Unity
run: |
set -x
pushd src/Momento.Sdk
rm -rf bin
VERSION="${{ needs.release.outputs.version }}"
echo "version: ${VERSION}"
dotnet publish --configuration Release -f netstandard2.0 -p:DefineConstants=USE_GRPC_WEB -p:VersionPrefix=${VERSION}
mkdir ./bin/Release/netstandard2.0/MomentoSdkUnity
pushd ./bin/Release/netstandard2.0/publish/
cp Google.Protobuf.dll Grpc.Core.Api.dll Grpc.Net.Client.dll Grpc.Net.Client.Web.dll Grpc.Net.Common.dll JWT.dll Microsoft.Bcl.AsyncInterfaces.dll Microsoft.Extensions.Logging.Abstractions.dll Momento.Protos.dll Momento.Sdk.Web.dll Newtonsoft.Json.dll System.Diagnostics.DiagnosticSource.dll System.Runtime.CompilerServices.Unsafe.dll System.Threading.Channels.dll ../MomentoSdkUnity/
popd
zip -jr MomentoSdkUnity.zip bin/Release/netstandard2.0/MomentoSdkUnity/
ZIP_FILE=./MomentoSdkUnity.zip
ARCHIVE_FILE_NAME=MomentoSdkUnity-${VERSION}.zip
AUTH="Authorization: token ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}"
LATEST_RELEASE=$(curl -sH "$AUTH" https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/v${VERSION})
RELEASE_ID=$(echo $LATEST_RELEASE | jq -r .id)
GH_ASSET="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${ARCHIVE_FILE_NAME}"
echo $GH_ASSET
curl --data-binary @$ZIP_FILE -H "$AUTH" -H "Content-Type: application/octet-stream" $GH_ASSET
popd