publish-draft-release.yml 5.03 KB
Newer Older
1
2
3
4
5
name: Publish draft release

on:
  push:
    tags:
6
7
      # Catches v1.2.3 and v1.2.3-rc1
      - v[0-9]+.[0-9]+.[0-9]+*
8
9

jobs:
Martin Pugh's avatar
Martin Pugh committed
10
11
12
13
14
15
16
17
18
19
20
21
22
  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)"

23
24
25
26
  build-runtimes:
    runs-on: ubuntu-latest
    strategy:
      matrix:
27
        runtime: ["polkadot", "kusama", "westend"]
28
    steps:
29
30
      - name: Checkout sources
        uses: actions/checkout@v2
31
32
33
      - name: Cache target dir
        uses: actions/cache@v2
        with:
34
          path: "${{ github.workspace }}/runtime/${{ matrix.runtime }}/target"
35
36
37
38
39
          key: srtool-target-${{ matrix.runtime }}-${{ github.sha }}
          restore-keys: |
            srtool-target-${{ matrix.runtime }}-
            srtool-target-
      - name: Build ${{ matrix.runtime }} runtime
40
41
42
43
44
45
46
        id: srtool_build
        uses: chevdor/srtool-actions@v0.3.0
        with:
          # This is the default with chevdor/srtool-actions@v0.3.0 but we make it clear
          image: paritytech/srtool
          chain: ${{ matrix.runtime }}
      - name: Store srtool digest to disk
47
        run: |
48
          echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.runtime }}_srtool_output.json
49
50
51
52
      - name: Upload ${{ matrix.runtime }} srtool json
        uses: actions/upload-artifact@v2
        with:
          name: ${{ matrix.runtime }}-srtool-json
Martin Pugh's avatar
Martin Pugh committed
53
          path: ${{ matrix.runtime }}_srtool_output.json
54
55
56
57
      - name: Upload ${{ matrix.runtime }} runtime
        uses: actions/upload-artifact@v2
        with:
          name: ${{ matrix.runtime }}-runtime
58
59
          path: |
            ${{ steps.srtool_build.outputs.wasm_compressed }}
60

61
62
  publish-draft-release:
    runs-on: ubuntu-latest
63
    needs: ["get-rust-versions", "build-runtimes"]
64
65
    outputs:
      release_url: ${{ steps.create-release.outputs.html_url }}
66
      asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
67
    steps:
68
69
      - name: Checkout sources
        uses: actions/checkout@v2
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
        with:
          fetch-depth: 0
          path: polkadot
      - name: Set up Ruby 2.7
        uses: actions/setup-ruby@v1
        with:
          ruby-version: 2.7
      - name: Download srtool json output
        uses: actions/download-artifact@v2
      - name: Generate release text
        env:
          RUSTC_STABLE: ${{ needs.get-rust-versions.outputs.rustc-stable }}
          RUSTC_NIGHTLY: ${{ needs.get-rust-versions.outputs.rustc-nightly }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
85
          gem install changelogerator:0.0.16 git toml
86
87
88
89
90
91
92
93
94
95
96
97
          ruby $GITHUB_WORKSPACE/polkadot/scripts/github/generate_release_text.rb | tee 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

98
99
  publish-runtimes:
    runs-on: ubuntu-latest
100
    needs: ["publish-draft-release"]
101
102
    strategy:
      matrix:
103
        runtime: ["polkadot", "kusama", "westend"]
104
    steps:
105
106
107
108
      - name: Checkout sources
        uses: actions/checkout@v2
      - name: Download artifacts
        uses: actions/download-artifact@v2
109
110
111
112
113
114
115
      - name: Set up Ruby 2.7
        uses: actions/setup-ruby@v1
        with:
          ruby-version: 2.7
      - name: Get runtime version
        id: get-runtime-ver
        run: |
Martin Pugh's avatar
Martin Pugh committed
116
117
          ls
          ls "${{ matrix.runtime }}-runtime"
118
119
          runtime_ver="$(ruby -e 'require "./scripts/github/lib.rb"; puts get_runtime("${{ matrix.runtime }}")')"
          echo "::set-output name=runtime_ver::$runtime_ver"
120
121
122
123
124
125
126
127
128
      - name: Upload compressed ${{ matrix.runtime }} wasm
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }}
          asset_path: "${{ matrix.runtime }}-runtime/${{ matrix.runtime }}_runtime.compact.compressed.wasm"
          asset_name: ${{ matrix.runtime }}_runtime-v${{ steps.get-runtime-ver.outputs.runtime_ver }}.compact.compressed.wasm
          asset_content_type: application/wasm
129
130
131
132
133
134

  post_to_matrix:
    runs-on: ubuntu-latest
    needs: publish-draft-release
    steps:
      - name: Internal polkadot channel
135
        uses: s3krit/matrix-message-action@v0.0.3
136
137
138
        with:
          room_id: ${{ secrets.INTERNAL_POLKADOT_MATRIX_ROOM_ID }}
          access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
139
          message: "**New version of polkadot tagged**: ${{ github.ref }}<br/>Draft release created: ${{ needs.publish-draft-release.outputs.release_url }}"
140
          server: "matrix.parity.io"