Skip to content

Commit

Permalink
Add changelog and release workflows (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
eike-hass authored Dec 6, 2021
1 parent 461a869 commit 723084f
Show file tree
Hide file tree
Showing 15 changed files with 861 additions and 94 deletions.
15 changes: 15 additions & 0 deletions .github/.github_changelog_generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
issues=true
issues-wo-labels=false
pr-wo-labels=false
author=false
breaking-label=Changed
breaking-labels=Breaking change
enhancement-label=Added
enhancement-labels=Added
bugs-label=Patch
bug-labels=Patch
deprecated-labels=Deprecated
removed-labels=Removed
exclude-labels=Documentation,No changelog
include-labels=Rust
verbose=true
43 changes: 43 additions & 0 deletions .github/actions/publish/publish-wasm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'publish-wasm'
description: 'Publishes Wasm bindings to npm'
inputs:
tag:
description: 'Which npm tag to publish under e.g. `dev`, will default to `latest`'
required: false
npm-token:
description: 'used for authenticating towards npm'
required: true
runs:
using: "composite"
steps:
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: wasm32-unknown-unknown

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'

- name: Install JS dependencies
shell: sh
run: npm install
working-directory: bindings/wasm

- name: Build WASM bindings
shell: sh
run: npm run build
working-directory: bindings/wasm

- name: Publish WASM bindings to NPM
shell: sh
env:
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
# will publish 'latest' tag if no tag is passed
run: npm publish $(if [ ${{ inputs.tag }} != '' ]; then echo --tag ${{ inputs.tag }}; fi) --access public
working-directory: bindings/wasm
69 changes: 69 additions & 0 deletions .github/actions/release/bump-versions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 'bump-versions'
description: 'Bump project versions for the release target'
inputs:
release-target:
description: "target of the release (rust|wasm)"
required: true
version:
description: "version to set (e.g. `1.2.3` or `1.2.3-dev.1`)"
required: true


runs:
using: "composite"
steps:
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Install cargo-workspaces
uses: actions-rs/cargo@v1
with:
command: install
args: --version ^0.2 cargo-workspaces

- name: Install cargo-edit # to use cargo add
uses: actions-rs/cargo@v1
if: ${{inputs.release-target == 'rust'}}
with:
command: install
args: -f --no-default-features --features "add" --version ^0.8 cargo-edit

- name: Replace identity version in Wasm bindings
shell: bash
if: ${{inputs.release-target == 'rust'}}
working-directory: bindings/wasm
run: |
cargo add identity@=${{ inputs.version }} --path=../../identity
- name: Bump Rust crate version
shell: bash
# cargo-release creates a signed commit automatically
if: ${{inputs.release-target == 'rust'}}
run: |
cargo workspaces version --no-git-commit --exact custom ${{ inputs.version }} -y
- name: Bump Wasm bindings crate version
shell: bash
# cargo-release creates a signed commit automatically
if: ${{inputs.release-target == 'wasm'}}
working-directory: bindings/wasm
run: |
cargo workspaces version --no-git-commit --exact custom ${{ inputs.version }} -y
- name: Set up Node.js
uses: actions/setup-node@v2
if: ${{inputs.release-target == 'wasm'}}
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'

- name: Bump Wasm npm package version
shell: bash
if: ${{inputs.release-target == 'wasm'}}
working-directory: bindings/wasm
run: |
npm version ${{ inputs.version }}
50 changes: 50 additions & 0 deletions .github/actions/release/changelog-generator/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'changelog-generator'
description: 'Runs github changelog generator'
inputs:
changelog-path:
description: "path to the changelog file"
required: false
default: ./CHANGELOG.md
changelog-config-path:
description: "path to the changelog config"
required: true
future-release:
description: "release name (e.g. `v1.2.3-dev.1`)"
required: true
optional-arg:
description: "optional argument for the generator command"
required: false
github-token:
description: "token used to call github API"
required: true

runs:
using: "composite"
steps:
- name: Prepare Repository For Changelog Generator
shell: bash
run: |
GITHUB_REPOSITORY_USER=$( echo $GITHUB_REPOSITORY | awk -F'/' '{print $1}')
GITHUB_REPOSITORY_PROJECT=$( echo $GITHUB_REPOSITORY | awk -F'/' '{print $2}')
echo GITHUB_REPOSITORY_USER=$GITHUB_REPOSITORY_USER
echo GITHUB_REPOSITORY_PROJECT=$GITHUB_REPOSITORY_PROJECT
echo GITHUB_REPOSITORY_USER=$GITHUB_REPOSITORY_USER >> $GITHUB_ENV
echo GITHUB_REPOSITORY_PROJECT=$GITHUB_REPOSITORY_PROJECT >> $GITHUB_ENV
- name: Run github-changelog-generator
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
args: >
--output ${{ inputs.changelog-path }}
--config-file ${{ inputs.changelog-config-path }}
--user ${{ env.GITHUB_REPOSITORY_USER }}
--project ${{ env.GITHUB_REPOSITORY_PROJECT }}
--token ${{ inputs.github-token }}
--future-release ${{ inputs.future-release }}
${{ inputs.optional-arg }}
- name: Log ${{ inputs.changelog-path }}
shell: bash
run: cat ${{ inputs.changelog-path }}
15 changes: 15 additions & 0 deletions .github/workflows/enforce-pr-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Enforce PR labels

on:
pull_request:
types: [labeled, unlabeled, opened, reopened, edited, synchronize]
jobs:
enforce-label:
runs-on: ubuntu-latest
steps:
- uses: yogevbd/enforce-label-action@a3c219da6b8fa73f6ba62b68ff09c469b3a1c024
with:
REQUIRED_LABELS_ANY: "Rust,Wasm,Documentation,No changelog"
- uses: yogevbd/enforce-label-action@a3c219da6b8fa73f6ba62b68ff09c469b3a1c024
with:
REQUIRED_LABELS_ANY: "Breaking change,Added,Patch,Deprecated,Removed,Documentation,No changelog"
48 changes: 0 additions & 48 deletions .github/workflows/publish-dev.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/publish.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/rust-automatic-release-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Rust Automatic Release and Publish

# Automatically creates a GitHub release and publishes the latest Rust crate versions to crates.io when a release PR is merged.
on:
pull_request:
branches:
- dev
- main
types: [closed]
jobs:
call-create-release-workflow:
if: github.event.pull_request.merged == true
# owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466
uses: iotaledger/identity.rs/.github/workflows/shared-release.yml@dev
with:
changelog-config-path: ./.github/.github_changelog_generator
dev-tag-regex: ^v[0-9]+\.[0-9]+\.[0-9]+-(dev)\.\d*$
main-tag-regex: ^v[0-9]+\.[0-9]+\.[0-9]+$
create-github-release: true
secrets:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
release:
runs-on: ubuntu-latest
needs: call-create-release-workflow
if: ${{ needs.call-create-release-workflow.outputs.is-release }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Dummy Publish to crates.io
# TODO: implement proper publish
run: echo beep boop, pretending to publish
44 changes: 44 additions & 0 deletions .github/workflows/rust-create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Rust Create Release PR

on:
workflow_dispatch:
inputs:
version:
description: 'Version to release Rust under (e.g. `1.2.3`)'
required: true
release-type:
description: Create a `dev` or `main` release. If `dev`, a `dev` postfix and auto-incrementing number will be added automatically (e.g. `1.2.3-dev.x`)'
type: choice
required: true
options:
- dev
- main

jobs:
create-dev-release-pr:
if: github.event.inputs.release-type == 'dev'
# owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466
uses: iotaledger/identity.rs/.github/workflows/shared-create-dev-release-pr.yml@dev
with:
tag-prefix: v
tag-postfix: -dev.
tag-base: ${{ github.event.inputs.version }}
main-tag-regex: ^v[0-9]+\.[0-9]+\.[0-9]+$
changelog-config-path: ./.github/.github_changelog_generator
release-target: rust
secrets:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
create-main-release-pr:
if: github.event.inputs.release-type == 'main'
# owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466
uses: iotaledger/identity.rs/.github/workflows/shared-create-main-release-pr.yml@dev
with:
tag-prefix: v
tag-base: ${{ github.event.inputs.version }}
main-tag-regex: ^v[0-9]+\.[0-9]+\.[0-9]+$
changelog-config-path: ./.github/.github_changelog_generator
release-target: rust
secrets:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
Loading

0 comments on commit 723084f

Please sign in to comment.