Skip to content

Commit

Permalink
fix(ci): refactor release (#5827)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Mar 29, 2020
1 parent b897658 commit cb56b54
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 53 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ coverage

# generated typescript code
**/*.generated.ts

27 changes: 2 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ jobs:
release:
needs: [lint, test, test-docker]
runs-on: ubuntu-latest
# release shouldn't need more than 30 min
timeout-minutes: 30
# release shouldn't need more than 5 min
timeout-minutes: 5

steps:
- name: Set up Node.js ${{ env.NODE_VERSION }}
Expand All @@ -282,7 +282,6 @@ jobs:
- uses: actions/checkout@v2

- name: Cache Yarn packages
id: yarn_cache_packages
uses: actions/cache@v1
with:
path: ${{ steps.init.outputs.yarn_cache }}
Expand All @@ -297,28 +296,6 @@ jobs:
- name: Installing dependencies
run: yarn install --frozen-lockfile --link-duplicates

- name: Build
run: yarn build

- name: Set up Docker Buildx ${{ env.BUILDX_VERSION }}
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: ${{ env.BUILDX_VERSION }}

- name: Docker registry login
if: github.ref == 'refs/heads/master'
run: echo "${{ secrets.DOCKER_RENOVATERELEASE_TOKEN }}" | docker login -u renovaterelease --password-stdin

- name: Update Docker images cache
continue-on-error: true
if: github.ref == 'refs/heads/master'
run: |
docker buildx bake \
--progress plain \
--file docker/bake.hcl \
--file docker/cache.hcl \
cache
- name: semantic-release
run: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ~/.npmrc
Expand Down
76 changes: 71 additions & 5 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,80 @@ on:
repository_dispatch:
types: [renovate-release]

env:
CI: true
DOCKER_REPO: renovate/renovate
YARN_CACHE_KEY: v1
BUILDX_VERSION: v0.3.1
NODE_VERSION: 12
# https://github.com/chalk/supports-color/issues/106
FORCE_COLOR: true

jobs:
release:
cache-docker:
runs-on: ubuntu-latest
steps:
- name: Init platform
id: init
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email 'bot@renovateapp.com'
git config --global user.name 'Renovate Bot'
- uses: actions/checkout@v2
with:
ref: ${{ github.event.client_payload.sha }}

- name: Set up Docker Buildx ${{ env.BUILDX_VERSION }}
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: ${{ env.BUILDX_VERSION }}

- name: Docker registry login
run: echo "${{ secrets.DOCKER_RENOVATERELEASE_TOKEN }}" | docker login -u renovaterelease --password-stdin

- name: Update Docker images cache
continue-on-error: true
run: |
docker buildx bake \
--progress plain \
--file docker/bake.hcl \
--file docker/cache.hcl \
cache
release-docker:
runs-on: ubuntu-latest
steps:
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}

- name: Init platform
id: init
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email 'bot@renovateapp.com'
git config --global user.name 'Renovate Bot'
- uses: actions/checkout@v2
with:
ref: ${{ github.event.client_payload.ref }}
ref: ${{ github.event.client_payload.sha }}

- name: Set up Docker Buildx ${{ env.BUILDX_VERSION }}
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: ${{ env.BUILDX_VERSION }}

- name: Docker registry login
run: echo "${{ secrets.DOCKER_RENOVATERELEASE_TOKEN }}" | docker login -u renovaterelease --password-stdin

- name: Prepare ${{ github.event.client_payload.version }}
run: |
npm --no-git-tag-version version ${{ github.event.client_payload.version }}
- run: echo 'docker release'
- run: echo ${{ github.event.client_payload.sha }}
- run: echo ${{ github.event.client_payload.version }}
- name: Publish ${{ github.event.client_payload.version }}
run: |
./.github/workflows/release-docker.sh ${{ github.event.client_payload.version }} ${{ github.event.client_payload.sha }}
60 changes: 55 additions & 5 deletions .github/workflows/release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,64 @@ on:
repository_dispatch:
types: [renovate-release]

env:
CI: true
YARN_CACHE_KEY: v1
BUILDX_VERSION: v0.3.1
NODE_VERSION: 12
# https://github.com/chalk/supports-color/issues/106
FORCE_COLOR: true

jobs:
release:
release-npm:
runs-on: ubuntu-latest
steps:
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}

- name: Init platform
id: init
run: |
echo "::set-output name=yarn_cache::$(yarn cache dir)"
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email 'bot@renovateapp.com'
git config --global user.name 'Renovate Bot'
yarn config set version-git-tag false
npm config set scripts-prepend-node-path true
- uses: actions/checkout@v2
with:
ref: ${{ github.event.client_payload.ref }}
ref: ${{ github.event.client_payload.sha }}

- name: Cache Yarn packages
id: yarn_cache_packages
uses: actions/cache@v1
with:
path: ${{ steps.init.outputs.yarn_cache }}
key: ${{ env.YARN_CACHE_KEY }}-${{ runner.os }}-yarn_cache-${{ hashFiles('**/yarn.lock') }}

- name: Cache node_modules
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Installing dependencies
run: yarn install --frozen-lockfile --link-duplicates

- name: Build ${{ github.event.client_payload.version }}
run: yarn build

- name: Prepare ${{ github.event.client_payload.version }}
run: |
npm --no-git-tag-version version ${{ github.event.client_payload.version }}
- run: echo 'npm release'
- run: echo ${{ github.event.client_payload.sha }}
- run: echo ${{ github.event.client_payload.version }}
- name: Publish ${{ github.event.client_payload.version }}
run: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ~/.npmrc
npm publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ junit.xml
/test-results
renovate-schema.json

# generated code
**/*.generated.ts
tools/dist
test/datasource/nuget/_fixtures/obj
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ bin/yarn*

# generated typescript code
**/*.generated.ts
tools/dist
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"build": "run-s clean generate:* compile:* copy-static-files",
"build:docker": "run-s generate:* compile:ts copy-static-files",
"clean": "rimraf dist lib/**/*.generated.ts",
"clean": "rimraf dist tools/dist lib/**/*.generated.ts",
"clean-cache": "node bin/clean-cache.js",
"compile:ts": "tsc -p tsconfig.app.json",
"compile:dts": "tsc -p tsconfig.dts.json",
Expand Down
34 changes: 17 additions & 17 deletions tools/release.mjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import shell from 'shelljs';
import { program, exec } from './utils.mjs';
import { program } from './utils.mjs';

const version = program.release;
const sha = program.sha;
// const sha = program.sha;

let err = false;
// let err = false;

shell.echo(`Publishing version: ${version}`);

shell.echo('Publishing npm package ...');
if (
!exec(`npm --no-git-tag-version version ${version}`) ||
!exec(`npm publish`)
) {
err = true;
}
// shell.echo('Publishing npm package ...');
// if (
// !exec(`npm --no-git-tag-version version ${version}`) ||
// !exec(`npm publish`)
// ) {
// err = true;
// }

shell.echo('Publishing docker images ...');
if (!exec(`./.github/workflows/release-docker.sh ${version} ${sha}`)) {
err = true;
}
// shell.echo('Publishing docker images ...');
// if (!exec(`./.github/workflows/release-docker.sh ${version} ${sha}`)) {
// err = true;
// }

// eslint-disable-next-line promise/valid-params
import('./dispatch-release.mjs').catch();

if (err) {
shell.exit(2);
}
// if (err) {
// shell.exit(2);
// }

0 comments on commit cb56b54

Please sign in to comment.