On push to release #67
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Build | |
run: dotnet build | |
- name: Pack and Publish | |
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: 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.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 |