Skip to content

Commit

Permalink
chore: rework release process (#1367)
Browse files Browse the repository at this point in the history
For details see the updated contributor documentation.
  • Loading branch information
latonz authored Jun 30, 2024
1 parent cc92662 commit 80036be
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 166 deletions.
33 changes: 33 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
change-template: '- $TITLE by @$AUTHOR in #$NUMBER'
change-title-escapes: '\<*_&'
sort-direction: ascending
exclude-labels:
- dependency
- no-changelog
- documentation
categories:
- title: '🚨 Breaking Changes'
labels:
- breaking-change
- title: '🚀 Features'
labels:
- enhancement
- title: '🐛 Bug Fixes'
labels:
- bug
version-resolver:
major:
labels:
- breaking-change
minor:
labels:
- enhancement
patch:
labels:
- bug
template: |
$CHANGES
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
18 changes: 0 additions & 18 deletions .github/workflows/conventional-commits.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo "building ${{ inputs.version }} for ${{ inputs.environment }}"
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
- run: dotnet tool restore
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/pr-label-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: pr-label-check

on:
pull_request:
types:
- opened
- synchronize
- labeled
- unlabeled

concurrency:
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
cancel-in-progress: true

jobs:
check-changelog-labels:
runs-on: ubuntu-latest
steps:
- name: PR has no changelog label
if: |
!contains(github.event.pull_request.labels.*.name, 'bug') &&
!contains(github.event.pull_request.labels.*.name, 'enhancement') &&
!contains(github.event.pull_request.labels.*.name, 'breaking-change') &&
!contains(github.event.pull_request.labels.*.name, 'no-changelog')
run: exit 1
29 changes: 29 additions & 0 deletions .github/workflows/release-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: draft-releases

on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}

jobs:
draft-releases:
permissions:
# write permission is required to create a github release
contents: write
pull-requests: read
runs-on: ubuntu-latest
steps:
- name: draft next
uses: leukeleu/release-drafter@filter-draft-releases
with:
prerelease: true
prerelease-identifier: next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: draft stable
uses: leukeleu/release-drafter@filter-draft-releases
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 0 additions & 49 deletions .github/workflows/release-preview.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/release-stable.yml

This file was deleted.

96 changes: 58 additions & 38 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,75 @@
name: release

on:
workflow_call:
inputs:
nuget_source:
required: false
type: string
default: 'https://api.nuget.org/v3/index.json'
environment:
required: true
type: string
secrets:
NUGET_API_TOKEN:
required: true
outputs:
version:
description: 'The created version'
value: ${{ jobs.release.outputs.version }}
release:
types:
- published

# required secrets: NUGET_API_TOKEN, CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NUGET_SOURCE: 'https://nuget.pkg.github.com/latonz/index.json' #'https://api.nuget.org/v3/index.json'

concurrency:
group: ${{ github.workflow }}

jobs:
release:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
environment: ${{ github.event.release.prerelease && 'next' || 'stable' }}
permissions:
contents: write
outputs:
version: ${{ steps.release-version.outputs.version }}
version: ${{ steps.extract-version.outputs.RELEASE_VERSION }}
steps:
- uses: actions/checkout@v4
- name: checkout git
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v4
- uses: actions/setup-node@v4
- id: extract-version
name: extract version
run: echo "RELEASE_VERSION=${RELEASE_NAME#v}" >> "$GITHUB_OUTPUT"
env:
RELEASE_NAME: ${{ github.event.release.name }}
- name: extract release notes
id: extract-release-notes
run: |
{
echo 'RELEASE_NOTES<<EOF';
gh release view '${{ github.event.release.name }}' --json body --jq .body;
echo 'EOF'
} >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
- name: convert release notes markdown to text
id: release-notes-text
uses: koistya/strip-markdown@v1
with:
node-version: '18'
- run: sudo apt update && sudo apt -y install zipmerge # zipmerge is used to merge the multi target nupkg
- run: |
npm i \
semantic-release@21.0.2 \
conventional-changelog-conventionalcommits@5.0.0 \
@semantic-release/exec@6.0.3 \
@semantic-release/commit-analyzer@9.0.2 \
@semantic-release/release-notes-generator@10.0.3 \
@semantic-release/github@8.0.7
- run: npx semantic-release
content: ${{ steps.extract-release-notes.outputs.RELEASE_NOTES }}
- name: setup dotnet
uses: actions/setup-dotnet@v4
- name: install dependencies
run: sudo apt update && sudo apt -y install zipmerge # zipmerge is used to merge the multi target nupkg
- name: build release
run: ./build/package.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_SOURCE: ${{ inputs.nuget_source }}
NUGET_API_TOKEN: ${{ secrets.NUGET_API_TOKEN }}
MAPPERLY_ENVIRONMENT: ${{ inputs.environment }}
- id: release-version
run: echo "version=${{ env.RELEASE_VERSION }}" >> "$GITHUB_OUTPUT"
MAPPERLY_ENVIRONMENT: ${{ github.event.release.prerelease && 'next' || 'stable' }}
RELEASE_NOTES: ${{ steps.release-notes-text.outputs.content }}
RELEASE_VERSION: ${{ steps.extract-version.outputs.RELEASE_VERSION }}
- name: publish nuget
run: dotnet nuget push './artifacts/*.nupkg' --source "$NUGET_SOURCE" --api-key '${{ secrets.NUGET_API_TOKEN }}'
- name: add release assets
run: gh release upload "${{ github.event.release.name }}" artifacts/*.nupkg
env:
GH_TOKEN: ${{ github.token }}
docs:
uses: ./.github/workflows/docs.yml
needs: release
with:
deploy: true
environment: ${{ github.event.release.prerelease && 'next' || 'stable' }}
version: ${{ needs.release.outputs.version }}
secrets:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
17 changes: 0 additions & 17 deletions .releaserc.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion build/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RELEASE_NOTES=${RELEASE_NOTES:-''}
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
artifacts_dir="${script_dir}/../artifacts"

echo "building Mapperly v${RELEASE_VERSION}"
echo "building Mapperly v${RELEASE_VERSION} for ${MAPPERLY_ENVIRONMENT:-'local'}"
echo "cleaning artifacts dir"
mkdir -p "${artifacts_dir}"
rm -rf "${artifacts_dir:?}"/*
Expand Down
17 changes: 1 addition & 16 deletions docs/docs/contributing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Before you submit your Pull Request (PR) consider the following guidelines:

6. Create your patch, including appropriate [test](./tests) cases and [documentation](./docs) updates.

7. Commit your changes using a descriptive commit message that follows our [commit message conventions](#commit).
7. Commit your changes using a descriptive commit message.
Adherence to these conventions is necessary because release notes are automatically generated from these messages.
[Husky](https://alirezanet.github.io/Husky.Net/) and [csharpier](https://csharpier.com/) automatically format changed files when commited.

Expand Down Expand Up @@ -111,18 +111,3 @@ For more information on the failure, check the output logs of the jobs.
The reviewers will provide you feedback and approve your changes as soon as they are satisfied.
If we ask you for changes in the code, you can follow the [GitHub Guide](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/incorporating-feedback-in-your-pull-request) to incorporate feedback in your pull request.
#### <a name="commit"></a> Commit message format
Make sure you use [conventional commit message format](https://www.conventionalcommits.org/en/v1.0.0/#summary).
`<type>: <short summary>`
#### Type
Must be one of the following:
- **feat**: New Feature
- **fix**: Bugfix
- **docs**: Documentation
- **chore**: Chores which should not lead to a changelog / release notes entry
Loading

0 comments on commit 80036be

Please sign in to comment.