Skip to content

Commit

Permalink
Fixes workflow draft release & Adds doc (paritytech#120)
Browse files Browse the repository at this point in the history
* Fixes workflow draft release & Adds doc

* Fixes draft conditions
  • Loading branch information
crystalin authored Nov 18, 2020
1 parent 59193a7 commit 8c15733
Showing 1 changed file with 79 additions and 76 deletions.
155 changes: 79 additions & 76 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
name: Release

on: ["push"]
# Using a single file workflow is the preferred solution for our CI over workflow_runs.
# 1. It generates only 1 action item in the list making it more readable
# 2. It includes the PR/Commit text in the action item
# 3. Artifacts are not available between workflows.

# This is only allowing pushes on the moonbeam repo or pull request.
# In the case of pull request, the CI executes the workflow from
# the commit the **PR is merging into**. This prevents malicious attack trying
# to change the CI in the PR.
####### DO NOT CHANGE THIS !! #######
on: ["push", "pull_request_target"]

jobs:
get-variables:
runs-on: ubuntu-latest
outputs:
tag-version: ${{ steps.variables.outputs.version }}
tag-exists: ${{ steps.variables.outputs.tag-exists }}
tag-count: ${{ steps.variables.outputs.count }}
sha-8: ${{ steps.variables.outputs.sha-8 }}
steps:
- uses: actions/checkout@v2
- id: variables
run: |
echo ::set-output name=version::$(git tag -l | tail -n1 | cut -c2- )
echo ::set-output name=count::$(git tag -l | wc -l )
echo ${{ github.ref }}
echo ::set-output name=tag-exists::$(git describe --exact-match HEAD 2>/dev/null && echo 1 || echo 0)
echo ::set-output name=sha-8::$(git rev-parse HEAD | cut -c1-8)
- id: show-variables
run: |
echo tag-version: ${{ steps.variables.outputs.version }}
echo tag-exists: ${{ steps.variables.outputs.tag-exists }}
echo tag-count: ${{ steps.variables.outputs.count }}
echo sha-8: ${{ steps.variables.outputs.sha-8 }}
####### Check files and formatting #######

check-copyright:
runs-on: ubuntu-latest
Expand All @@ -40,6 +29,37 @@ jobs:
false
fi
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: "yes"

check-editorconfig:
name: "Check editorconfig"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup editorconfig checker
run: |
wget https:/editorconfig-checker/editorconfig-checker/releases/download/2.1.0/ec-linux-amd64.tar.gz
tar xvf ec-linux-amd64.tar.gz
chmod +x bin/ec-linux-amd64
- name: Check files
run: bin/ec-linux-amd64

check-prettier:
name: "Check with Prettier"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check with Prettier
run: npx prettier --check --ignore-path .gitignore **.json **.js **.ts **.yml

####### Building and Testing binaries #######

build:
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -98,6 +118,28 @@ jobs:
name: moonbase-standalone
path: build/standalone

####### Checking generated Cargo files #######

check-cargo-toml:
runs-on: ubuntu-latest
needs: build
steps:
# We determine whether there are unmodified Cargo.lock files by:
# 1. Asking git for a list of all modified files
# 2. Using grep to reduce the list to only Cargo.lock files
# 3. Counting the number of lines of output
- run: |
FILECOUNT=$(git diff-index --name-only HEAD | grep Cargo.lock | wc -l)
if [[ $FILECOUNT -eq 0 ]]; then
echo "All lock files are valid"
else
echo "The following Cargo.lock files have uncommitted changes"
git diff-index --name-only HEAD | grep Cargo.lock
false
fi
####### Prepare and Deploy Docker images #######

generate-parachain-specs:
runs-on: ubuntu-latest
needs: build
Expand All @@ -119,8 +161,8 @@ jobs:

docker-parachain:
runs-on: ubuntu-latest
needs: ["get-variables", "build", "generate-parachain-specs"]
if: needs.get-variables.outputs.tag-exists == 0 && github.event_name != 'pull_request'
needs: ["build", "generate-parachain-specs"]
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
Expand Down Expand Up @@ -189,8 +231,8 @@ jobs:
docker-standalone:
runs-on: ubuntu-latest
needs: ["get-variables", "build"]
if: needs.get-variables.outputs.tag-exists == 0 && github.event_name != 'pull_request'
needs: ["build"]
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
Expand Down Expand Up @@ -257,10 +299,14 @@ jobs:
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
####### Prepare the release draft #######

publish-draft-release:
runs-on: ubuntu-latest
needs: ["build", "generate-parachain-specs"]
if: needs.get-tag-version.outputs.tag-exists == 1
if: |
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/v')
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
Expand Down Expand Up @@ -294,7 +340,11 @@ jobs:
publish-runtimes:
runs-on: ubuntu-latest
needs: ["publish-draft-release"]
if: needs.get-tag-version.outputs.tag-exists == 1
# We want to store the binaries also when it is not a version release. This is used
# in case such as providing binaries when creating a new tutorial version.
if: |
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
runtime: ["moonbase-alphanet"]
Expand Down Expand Up @@ -358,50 +408,3 @@ jobs:
asset_path: build/alphanet/${{ matrix.runtime }}-genesis.txt
asset_name: ${{ matrix.runtime }}-genesis.txt
asset_content_type: text/plain

check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: "yes"

check-editorconfig:
name: "Check editorconfig"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup editorconfig checker
run: |
wget https:/editorconfig-checker/editorconfig-checker/releases/download/2.1.0/ec-linux-amd64.tar.gz
tar xvf ec-linux-amd64.tar.gz
chmod +x bin/ec-linux-amd64
- name: Check files
run: bin/ec-linux-amd64

check-prettier:
name: "Check with Prettier"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check with Prettier
run: npx prettier --check --ignore-path .gitignore **.json **.js **.ts **.yml

check-cargo-toml:
runs-on: ubuntu-latest
needs: build
steps:
# We determine whether there are unmodified Cargo.lock files by:
# 1. Asking git for a list of all modified files
# 2. Using grep to reduce the list to only Cargo.lock files
# 3. Counting the number of lines of output
- run: |
FILECOUNT=$(git diff-index --name-only HEAD | grep Cargo.lock | wc -l)
if [[ $FILECOUNT -eq 0 ]]; then
echo "All lock files are valid"
else
echo "The following Cargo.lock files have uncommitted changes"
git diff-index --name-only HEAD | grep Cargo.lock
false
fi

0 comments on commit 8c15733

Please sign in to comment.