mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-04-25 09:39:34 -04:00
120 lines
4.5 KiB
YAML
120 lines
4.5 KiB
YAML
name: Prepare Crypto-Node.js Release
|
|
#
|
|
# This is a helper workflow to craft a new Node.js release, trigger this via
|
|
# the Github Workflow UI by dispatching it manually. Provide the version, the
|
|
# matrix-sdk-crypto-nodejs npm package should be set to, and a optionally the
|
|
# old version (as used in the git tag) this release should be compared to.
|
|
#
|
|
# This will then:
|
|
# 1. bump the npm version to the one you specified
|
|
# 2. commit that change together with the changelog (if it changed, see below)
|
|
# 3. create the appropriate tag on that commit
|
|
# 4. create the Github draft release, including the changes (if given, see below)
|
|
# 5. push these to a new branch, including tag, triggering the `release-crypto-nodejs` workflow
|
|
# 6. create a PR to merge these back into `main`
|
|
#
|
|
# Additionally, if you provide a tag to comapare this tag to, this will:
|
|
# 1. create a changelog between the two releases, used for the github release
|
|
# 2. update the Changelog.md and include it in the commit
|
|
#
|
|
# The remaining tasks are done by the release-crypto-nodejs workflow.
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'New Node.js SemVer version to create'
|
|
required: true
|
|
type: string
|
|
previous_version:
|
|
description: 'Create the changelog by comparing to this old SemVer Version (as used in the tag) '
|
|
type: string
|
|
|
|
env:
|
|
PKG_PATH: "bindings/matrix-sdk-crypto-nodejs"
|
|
TAG_PREFIX: "matrix-sdk-crypto-nodejs-v"
|
|
|
|
jobs:
|
|
prepare-release:
|
|
name: "Preparing crypto-nodejs release tag"
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
tag: "${{ env.TAG_PREFIX }}${{ inputs.version }}"
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-node@v3
|
|
|
|
# Generate changelog since last tag, if given
|
|
- name: Generate a changelog for upload
|
|
if: inputs.previous_version
|
|
uses: orhun/git-cliff-action@v1
|
|
with:
|
|
config: "${{ env.PKG_PATH }}/cliff.toml"
|
|
args: --strip header "${{env.TAG_PREFIX}}${{ inputs.previous_version }}..HEAD"
|
|
env:
|
|
GIT_CLIFF_TAG: "Changes ${{ inputs.previous_version }} -> ${{ inputs.version }}"
|
|
GIT_CLIFF_OUTPUT: "${{ env.PKG_PATH }}/CHANGES-${{ inputs.version }}.md"
|
|
|
|
# Update changelog since last tag, if given
|
|
- name: Update existing Changelog
|
|
if: inputs.previous_version
|
|
uses: orhun/git-cliff-action@v1
|
|
with:
|
|
config: "${{ env.PKG_PATH }}/cliff.toml"
|
|
args: "${{env.TAG_PREFIX}}${{ inputs.previous_version }}..HEAD"
|
|
env:
|
|
GIT_CLIFF_TAG: "${{ inputs.version }}"
|
|
GIT_CLIFF_PREPEND: "${{ env.PKG_PATH }}/CHANGELOG.md"
|
|
|
|
- name: Set version
|
|
id: package_version
|
|
working-directory: ${{ env.PKG_PATH }}
|
|
run: npm version ${{ inputs.version }}
|
|
|
|
- uses: EndBug/add-and-commit@v9
|
|
with:
|
|
default_author: github_actions
|
|
message: "Tagging Crypto-Node.js for release"
|
|
tag: "${{env.TAG_PREFIX}}${{ inputs.version }}"
|
|
new_branch: "gh-action/release-${{ env.TAG_PREFIX }}${{ inputs.version }}"
|
|
push: true
|
|
add: |
|
|
${{ env.PKG_PATH }}/package.json
|
|
${{ env.PKG_PATH }}/CHANGELOG.md
|
|
|
|
# if we have generated changes
|
|
- name: Update Github Release notes
|
|
if: inputs.previous_version
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
draft: true
|
|
tag_name: ${{ env.TAG_PREFIX }}${{ inputs.version }}
|
|
body_path: "${{ env.PKG_PATH }}/CHANGES-${{ inputs.version }}.md"
|
|
|
|
# no changes, use the default changelog for the body
|
|
- name: Update Github Release notes
|
|
if: ${{!inputs.previous_version}}
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
draft: true
|
|
tag_name: ${{ env.TAG_PREFIX }}${{ inputs.version }}
|
|
body_path: "${{ env.PKG_PATH }}/CHANGELOG.md"
|
|
|
|
# let's create a PR for all this, too
|
|
- name: Create Pull Request
|
|
uses: peter-evans/create-pull-request@v4
|
|
with:
|
|
title: "Preparing Release ${{ env.TAG_PREFIX }}${{ inputs.version }}"
|
|
body: |
|
|
Automatic Pull-Request to merge release ${{ env.TAG_PREFIX }}${{ inputs.version }}
|
|
|
|
trigger-release:
|
|
# and trigger the tagging release workflow
|
|
uses: ./.github/workflows/release-crypto-nodejs.yml
|
|
needs: ['prepare-release']
|
|
name: "Trigger release Workflow"
|
|
with:
|
|
tag: ${{needs.prepare-release.outputs.tag}}
|
|
secrets:
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|