Skip to content

Commit

Permalink
TMP
Browse files Browse the repository at this point in the history
  • Loading branch information
Devil7DK committed Jun 26, 2023
1 parent f7a4612 commit 21a1132
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/tmp_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Workflow for building and creating a release
name: Build

on:
push:
# branches:
# - master
tags:
- v*

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Create Secrets
uses: danielr1996/[email protected]
env:
GDRIVE_CLIENT_ID: ${{ secrets.GDRIVE_CLIENT_ID }}
GDRIVE_CLIENT_SECRET: ${{ secrets.GDRIVE_CLIENT_SECRET }}
GDRIVE_PROJECT_ID: ${{ secrets.GDRIVE_PROJECT_ID }}
with:
input: Utils/Secrets.ci.cs
output: Utils/Secrets.cs
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Get changelog
if: startsWith(github.ref, 'refs/tags/v')
run: sh ./git-changelog.sh
id: changelog
- name: Publish
if: startsWith(github.ref, 'refs/tags/v')
run: |
dotnet publish --configuration Release --framework net7.0 --runtime win-x86 --output ./publish/win-x86 --no-self-contained
dotnet publish --configuration Release --framework net7.0 --runtime win-x86 --output ./publish/win-x86-self --self-contained
dotnet publish --configuration Release --framework net7.0 --runtime win-x64 --output ./publish/win-x64 --no-self-contained
dotnet publish --configuration Release --framework net7.0 --runtime win-x64 --output ./publish/win-x64-self --self-contained
dotnet publish --configuration Release --framework net7.0 --runtime linux-x64 --output ./publish/linux-x64 --no-self-contained
dotnet publish --configuration Release --framework net7.0 --runtime linux-x64 --output ./publish/linux-x64-self --self-contained
dotnet publish --configuration Release --framework net7.0 --runtime linux-arm --output ./publish/linux-arm --no-self-contained
dotnet publish --configuration Release --framework net7.0 --runtime linux-arm --output ./publish/linux-arm-self --self-contained
dotnet publish --configuration Release --framework net7.0 --runtime osx-x64 --output ./publish/osx-x64 --no-self-contained
dotnet publish --configuration Release --framework net7.0 --runtime osx-x64 --output ./publish/osx-x64-self --self-contained
zip -j9 ./publish/google-drive-client_win-x86.zip ./publish/win-x86/*
zip -j9 ./publish/google-drive-client_win-x86_self-contained.zip ./publish/win-x86-self/*
zip -j9 ./publish/google-drive-client_win-x64.zip ./publish/win-x64/*
zip -j9 ./publish/google-drive-client_win-x64_self-contained.zip ./publish/win-x64-self/*
tar -cvzf ./publish/google-drive-client_linux-x64.tar.gz -C ./publish/linux-x64 .
tar -cvzf ./publish/google-drive-client_linux-x64_self-contained.tar.gz -C ./publish/linux-x64-self .
tar -cvzf ./publish/google-drive-client_linux-arm.tar.gz -C ./publish/linux-arm .
tar -cvzf ./publish/google-drive-client_linux-arm_self-contained.tar.gz -C ./publish/linux-arm-self .
tar -cvzf ./publish/google-drive-client_osx-x64.tar.gz -C ./publish/osx-x64 .
tar -cvzf ./publish/google-drive-client_osx-x64_self-contained.tar.gz -C ./publish/osx-x64-self .
- name: Create release
if: startsWith(github.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
artifacts: "publish/google-drive-client_*"
body: ${{ steps.changelog.outputs.CHANGELOG }}
draft: true
prerelease: false
28 changes: 28 additions & 0 deletions git-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

get_commit_messages()
{
# Finds the id of a commit that matches "Bump Version to *.*.*" commit message skipping last one
previous_commit=$(git rev-list HEAD~ --grep=".*[V|v]ersion to .*")

# If there is no commit that matches the above condition, find the initial commit id.
if [ -z "$previous_commit" ];then
previous_commit=$(git rev-list HEAD --max-parents=0)
fi

# Lists all commit messages from $previous_commit to HEAD~
#
# sed '/^$/d' = Removes all empty lines
# sed -e 's/^/* /' = Appends asterisk (*) to each line
# sed 's/\//\\\//g' = Escaps forward slash i.e. '/' to '\/'
# sed 's/\\/\\\\/g' = Escaps backward slash i.e '\' to '\\'
# sed 's/\"/\\\"/g' = Escaps double quotes (")
# sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g' = Replaces newline charecter with newline litral i.e. '<newline>' to '\n'
#
# All the above filters are required to keep the json payload valid.
echo "$(git log $previous_commit..HEAD~ --format=%B | sed '/^$/d' | sed -e 's/^/* /' | sed 's/\//\\\//g' | sed 's/\\/\\\\/g' | sed 's/\"/\\\"/g' | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g' | tr '\n' '\\n')"
}

CHANGELOG="$(get_commit_messages)"
echo $CHANGELOG
echo "CHANGELOG=$CHANGELOG" >> $GITHUB_OUTPUT

0 comments on commit 21a1132

Please sign in to comment.