Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/publish-draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Publish draft release

on:
push:
tags:
- v**.**.**

jobs:
get-rust-versions:
runs-on: ubuntu-latest
container:
image: paritytech/ci-linux:production
outputs:
rustc-stable: ${{ steps.get-rust-versions.outputs.stable }}
rustc-nightly: ${{ steps.get-rust-versions.outputs.nightly }}
steps:
- id: get-rust-versions
run: |
echo "::set-output name=stable::$(rustc +stable --version)"
echo "::set-output name=nightly::$(rustc +nightly --version)"

publish-draft-release:
runs-on: ubuntu-latest
needs: get-rust-versions
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
path: polkadot
- name: Set up Ruby 2.7
uses: actions/setup-ruby@v1
with:
ruby-version: 2.7
- name: Generate release text
env:
RUSTC_STABLE: ${{ needs.get-rust-versions.outputs.rustc-stable }}
RUSTC_NIGHTLY: ${{ needs.get-rust-versions.outputs.rustc-nightly }}
run: |
gem install changelogerator git toml
ruby $GITHUB_WORKSPACE/polkadot/scripts/github/generate_release_text.rb > release_text.md
- uses: actions/upload-artifact@v2
with:
name: release_text
path: release_text.md
- name: Create draft release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Polkadot ${{ github.ref }}
body_path: ./release_text.md
draft: true

post_to_matrix:
runs-on: ubuntu-latest
needs: publish-draft-release
steps:
- name: Internal polkadot channel
uses: s3krit/[email protected]
with:
room_id: ${{ secrets.INTERNAL_POLKADOT_MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: "**New version of polkadot tagged**: ${{ github.ref }}<br/>Gav: Draft release created: ${{ needs.publish-draft-release.outputs.release_url }}"
server: "matrix.parity.io"
11 changes: 0 additions & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,6 @@ check-line-width:
interruptible: true
allow_failure: true

publish-draft-release:
stage: test
only:
- tags
- /^v[0-9]+\.[0-9]+\.[0-9]+.*$/ # i.e. v1.0.1, v2.1.0rc1
script:
- apt-get -y update; apt-get -y install jq
- ./scripts/gitlab/publish_draft_release.sh
interruptible: true
allow_failure: true

test-deterministic-wasm:
stage: test
<<: *docker-env
Expand Down
74 changes: 74 additions & 0 deletions scripts/github/generate_release_text.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# frozen_string_literal: true

require 'changelogerator'
require 'git'
require 'erb'
require 'toml'

version = ENV['GITHUB_REF']
token = ENV['GITHUB_TOKEN']

polkadot_path = ENV['GITHUB_WORKSPACE'] + '/polkadot/'
pg = Git.open(polkadot_path)

# Generate an ERB renderer based on the template .erb file
renderer = ERB.new(
File.read(ENV['GITHUB_WORKSPACE'] + '/polkadot/scripts/github/polkadot_release.erb'),
trim_mode: '<>'
)

# get last polkadot version. Use handy Gem::Version for sorting by version
last_version = pg
.tags
.map(&:name)
.grep(/^v\d+\.\d+\.\d+.*$/)
.sort_by { |v| Gem::Version.new(v.slice(1...)) }[-2]

polkadot_cl = Changelog.new(
'paritytech/polkadot', version, last_version, token: token
)

# Get prev and cur substrate SHAs - parse the old and current Cargo.lock for
# polkadot and extract the sha that way.
prev_cargo = TOML::Parser.new(pg.show("#{last_version}:Cargo.lock")).parsed
current_cargo = TOML::Parser.new(pg.show("#{version}:Cargo.lock")).parsed

substrate_prev_sha = prev_cargo['package']
.find { |p| p['name'] == 'sc-cli' }['source']
.split('#').last

substrate_cur_sha = current_cargo['package']
.find { |p| p['name'] == 'sc-cli' }['source']
.split('#').last

substrate_cl = Changelog.new(
'paritytech/substrate', substrate_prev_sha, substrate_cur_sha,
token: token,
prefix: true
)

all_changes = polkadot_cl.changes + substrate_cl.changes

# Set all the variables needed for a release

misc_changes = Changelog.changes_with_label(all_changes, 'B1-releasenotes')
client_changes = Changelog.changes_with_label(all_changes, 'B5-clientnoteworthy')
runtime_changes = Changelog.changes_with_label(all_changes, 'B7-runtimenoteworthy')

release_priority = Changelog.highest_priority_for_changes(all_changes)

# Pulled from the previous Github step
rustc_stable = ENV['RUSTC_STABLE']
rustc_nightly = ENV['RUSTC_NIGHTLY']

polkadot_runtime = File.open(polkadot_path + '/runtime/polkadot/src/lib.rs') do |f|
f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0]
end
kusama_runtime = File.open(polkadot_path + '/runtime/kusama/src/lib.rs') do |f|
f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0]
end
westend_runtime = File.open(polkadot_path + '/runtime/westend/src/lib.rs') do |f|
f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0]
end

puts renderer.result
36 changes: 36 additions & 0 deletions scripts/github/polkadot_release.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<%= print release_priority[:text] %> <%= puts " due to changes: *#{Changelog.changes_with_label(all_changes, release_priority[:label]).map(&:pretty_title).join(", ")}*" if release_priority[:priority] > 1 %>

Native runtimes:

- Polkadot: **<%= polkadot_runtime %>**
- Kusama: **<%= kusama_runtime %>**
- Westend: **<%= westend_runtime %>**

This release was tested against the following versions of `rustc`. Other versions may work.

- <%= rustc_stable %>
- <%= rustc_nightly %>

<% unless misc_changes.empty? %>
## Changes

<% misc_changes.each do |c| %>
* <%= c[:pretty_title] %>
<% end %>
<% end %>

<% unless client_changes.empty? %>
## Client

<% client_changes.each do |c| %>
* <%= c[:pretty_title] %>
<% end %>
<% end %>

<% unless runtime_changes.empty? %>
## Runtime

<% runtime_changes.each do |c| %>
* <%= c[:pretty_title] %>
<% end %>
<% end %>
Loading