Skip to content

Commit

Permalink
🖆 Apply kzu/oss template via dotnet-file
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed Mar 30, 2021
1 parent a8775f1 commit 46092d7
Show file tree
Hide file tree
Showing 18 changed files with 422 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: devlooped
github: devlooped
37 changes: 37 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: changelog
on:
release:
types: [released]

env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

jobs:
changelog:
runs-on: ubuntu-latest
steps:
- name: 🔍 GH_TOKEN
if: env.GH_TOKEN == ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "GH_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV

- name: 🤘 checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main
token: ${{ env.GH_TOKEN }}

- name: ⚙ changelog
uses: faberNovel/github-changelog-generator-action@master
with:
options: --token ${{ secrets.GITHUB_TOKEN }} --o changelog.md

- name: 🚀 changelog
run: |
git config --local user.name github-actions
git config --local user.email github-actions@github.com
git add changelog.md
git commit -m "🖉 Update changelog with ${GITHUB_REF#refs/*/}"
git push
58 changes: 58 additions & 0 deletions .github/workflows/dotnet-file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Synchronizes .netconfig-configured files with dotnet-file
name: dotnet-file
on:
schedule:
- cron: "0 0 * * *"
push:
branches: [ 'dotnet-file' ]

env:
DOTNET_NOLOGO: true
GH_TOKEN: ${{ secrets.GH_TOKEN }}

jobs:
sync:
runs-on: windows-latest
steps:
- name: 🔍 GH_TOKEN
if: env.GH_TOKEN == ''
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "GH_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV

- name: 🤘 checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main
token: ${{ env.GH_TOKEN }}

- name: 🔄 sync
run: |
dotnet tool update -g dotnet-gcm
dotnet gcm store --protocol=https --host=github.com --username=$env:GITHUB_ACTOR --password=$env:GH_TOKEN
gh auth status
dotnet tool update -g dotnet-file
dotnet file sync -c:$env:TEMP\dotnet-file.md
if (test-path $env:TEMP\dotnet-file.md) {
echo 'CHANGES<<EOF' >> $env:GITHUB_ENV
cat $env:TEMP\dotnet-file.md >> $env:GITHUB_ENV
echo 'EOF' >> $env:GITHUB_ENV
cat $env:TEMP\dotnet-file.md
} else {
echo 'No changelog was generated'
}
- name: ✍ pull request
uses: peter-evans/create-pull-request@v3
with:
base: main
branch: dotnet-file-sync
commit-message: Bump files with dotnet-file sync

${{ env.CHANGES }}
title: "Bump files with dotnet-file sync"
body: ${{ env.CHANGES }}
token: ${{ env.GH_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
git add -A
git config --local user.email "hello@clarius.org"
git config --local user.name "GitHub Action"
git commit -m "Publish ${GITHUB_REPOSITORY}@${GITHUB_SHA:0:9}"
git commit -m "Publish pages from ${GITHUB_REPOSITORY}@${GITHUB_SHA:0:9}"
- name: 🚀 push
uses: ad-m/github-push-action@v0.6.0
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Builds a final release version and pushes to nuget.org
# whenever a release is published.
# Requires: secrets.NUGET_API_KEY

name: publish
on:
release:
types: [released]

env:
DOTNET_NOLOGO: true
Configuration: Release

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: 🤘 checkout
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- name: 🙏 build
run: dotnet build -m:1 -bl:build.binlog -p:version=${GITHUB_REF#refs/*/v} -p:RepositoryBranch=${GITHUB_REF#refs/*/}

- name: 🧪 test
run: dotnet test --no-build -m:1

- name: 📦 pack
run: dotnet pack -m:1 -bl:pack.binlog -p:version=${GITHUB_REF#refs/*/v} -p:RepositoryBranch=${GITHUB_REF#refs/*/}

- name: 🔼 logs
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
path: '**/*.binlog'

- name: 🚀 nuget
run: dotnet nuget push ./bin/**/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate
49 changes: 49 additions & 0 deletions .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Builds a release version of the project and uploads
# as artifacts of the release for verification/history

name: release-artifacts
on:
release:
types: [published]

jobs:
release-artifacts:
runs-on: ubuntu-latest
steps:
- name: 🤘 checkout
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- name: 🏷 current
run: echo "CURRENT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: 🙏 build
run: dotnet build -m:1 -bl:build.binlog -p:version=${GITHUB_REF#refs/*/v} -p:RepositoryBranch=${GITHUB_REF#refs/*/}

- name: 🧪 test
run: dotnet test --no-build -m:1

- name: 📦 pack
run: dotnet pack -m:1 -bl:pack.binlog -p:version=${GITHUB_REF#refs/*/v} -p:RepositoryBranch=${GITHUB_REF#refs/*/}

- name: 🔼 logs
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
path: '**/*.binlog'

- name: 🔽 gh
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install gh
- name: 🔼 artifacts
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gci .\bin -Recurse -Filter *.nupkg | %{ gh release upload --clobber $env:CURRENT_TAG $_ }
56 changes: 56 additions & 0 deletions .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Updates a release with release notes
name: release-notes

on:
release:
types: [published]

jobs:
release-notes:
runs-on: ubuntu-latest
steps:
- name: 🤘 checkout
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- name: 🏷 current
run: echo "CURRENT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: 🏷 since
run: echo "SINCE_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))" >> $GITHUB_ENV

- name: ⚙ changelog
uses: faberNovel/github-changelog-generator-action@master
if: env.SINCE_TAG != ''
with:
options: --token ${{ secrets.GITHUB_TOKEN }} --since-tag ${{ env.SINCE_TAG }} --o changelog.md

- name: ⚙ changelog
uses: faberNovel/github-changelog-generator-action@master
if: env.SINCE_TAG == ''
with:
options: --token ${{ secrets.GITHUB_TOKEN }} --o changelog.md

- name: 🖉 release
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$id = iwr "$env:GITHUB_API_URL/repos/$env:GITHUB_REPOSITORY/releases/tags/$env:CURRENT_TAG" |
select -ExpandProperty Content |
ConvertFrom-Json |
select -ExpandProperty id
$notes = (Get-Content .\changelog.md | where { !($_ -like '\*') } | %{ $_.replace('\', '\\') }) -join '\n'
$headers = @{ 'Accept'='application/vnd.github.v3+json;charset=utf-8'; 'Authorization' = "bearer $env:GITHUB_TOKEN" }
$body = '{ "body":"' + $notes + '" }'
# ensure we can convert to json
$body | ConvertFrom-Json | ConvertTo-Json
# patch & render response nicely
iwr -Body $body "$env:GITHUB_API_URL/repos/$env:GITHUB_REPOSITORY/releases/$id" -Method PATCH -Headers $headers |
select -ExpandProperty Content |
ConvertFrom-Json |
ConvertTo-Json
59 changes: 59 additions & 0 deletions .github/workflows/sponsors.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
$event = Get-Content -Path $env:GITHUB_EVENT_PATH | ConvertFrom-Json
$author = $event.issue ? $event.issue.user.node_id : $event.pull_request.user.node_id

if ($author -eq $null) {
throw 'No user id found'
}

gh auth status

echo "Looking up sponsorship from $env:GITHUB_ACTOR ..."

$query = gh api graphql --paginate -f owner='devlooped' -f query='
query($owner: String!, $endCursor: String) {
organization (login: $owner) {
sponsorshipsAsMaintainer (first: 100, after: $endCursor) {
nodes {
sponsorEntity {
... on Organization { id, name }
... on User { id, name }
}
tier { monthlyPriceInDollars }
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
'

$amount =
$query |
ConvertFrom-Json |
select @{ Name='nodes'; Expression={$_.data.organization.sponsorshipsAsMaintainer.nodes}} |
select -ExpandProperty nodes |
where { $_.sponsorEntity.id -eq $author } |
select -ExpandProperty tier |
select -ExpandProperty monthlyPriceInDollars

if ($null -eq $amount) {
echo "Author is not a sponsor! Nothing left to do."
return
}

echo "Author is a sponsor!"

$headers = @{ 'Accept'='application/vnd.github.v3+json;charset=utf-8'; 'Authorization' = "bearer $env:GH_TOKEN" }

# Try creating the labels, ignore errors (i.e. already created)
iwr -Body '{ "name":"sponsor :purple_heart:", "color":"ea4aaa", "description":"sponsor" }' "$env:GITHUB_API_URL/repos/$env:GITHUB_REPOSITORY/labels" -Method Post -Headers $headers -SkipHttpErrorCheck -UseBasicParsing | select -ExpandProperty StatusCode
iwr -Body '{ "name":"sponsor :yellow_heart:", "color":"ea4aaa", "description":"sponsor++" }' "$env:GITHUB_API_URL/repos/$env:GITHUB_REPOSITORY/labels" -Method Post -Headers $headers -SkipHttpErrorCheck -UseBasicParsing | select -ExpandProperty StatusCode

$number = $event.issue ? $event.issue.number : $event.pull_request.number
$labels = $amount -ge 100 ? '{"labels":["sponsor :yellow_heart:"]}' : '{"labels":["sponsor :purple_heart:"]}'

iwr -Body $labels "$env:GITHUB_API_URL/repos/$env:GITHUB_REPOSITORY/issues/$number/labels" -Method Post -Headers $headers -SkipHttpErrorCheck -UseBasicParsing | select -ExpandProperty StatusCode

echo 'Label applied'
25 changes: 25 additions & 0 deletions .github/workflows/sponsors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Runs on new issues/PRs and applies sponsor labels

name: sponsors
on:
pull_request:
types: [opened]
issues:
types: [opened]

jobs:
sponsors:
runs-on: windows-latest
steps:
- name: 🤘 checkout
uses: actions/checkout@v2

- name: 🔽 gh
run: |
iwr -useb get.scoop.sh | iex
scoop install gh
- name: 💛 sponsors
run: ./.github/workflows/sponsors.ps1
env:
GH_TOKEN: ${{ secrets.DEVLOOPED_TOKEN }}
Loading

0 comments on commit 46092d7

Please sign in to comment.