Skip to content

Commit

Permalink
add release process
Browse files Browse the repository at this point in the history
  • Loading branch information
yimysty committed Feb 7, 2022
1 parent c96882a commit 0c8c980
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 117 deletions.
38 changes: 38 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
# Changelog
$CHANGES
See details of [all code changes](https://github.com/actions/jekyll-build-pages/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
labels:
- 'infrastructure'
- 'automation'
- 'documentation'
- title: '🏎 Performance'
label: 'performance'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
version-resolver:
major:
labels:
- 'type: breaking'
minor:
labels:
- 'type: enhancement'
patch:
labels:
- 'type: bug'
- 'type: maintenance'
- 'type: documentation'
default: patch
54 changes: 18 additions & 36 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,9 @@ on:
push:
branches:
- 'main'
paths-ignore:
- 'README.md'
# Publish semver tags as releases. Allow for '-alpha'
# stage releases as well.
- 'feature-*'
tags:
- 'v*.*.*-beta'
- 'v*.*.*-alpha'
- 'v*'
pull_request:
branches:
- 'main'
paths-ignore:
- 'README.md'

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
Expand All @@ -40,15 +29,21 @@ jobs:
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Generate Image Tags
id: generate-image-tags
run: |
# Generate tags for the image
if [[ "${{ github.ref_name }}" == "main" ]]; then
tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
else
tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
fi
echo "::set-output name=tags::$tags"
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
Expand All @@ -62,24 +57,11 @@ jobs:
with:
context: .
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
push: true
tags: ${{ steps.generate-image-tags.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Render Action Metadata
if: ${{ github.event_name != 'pull_request' }}
run: |
./bin/render_action_metadata "docker://ghcr.io/actions/jekyll-build-pages:${{ github.ref_name }}" > action.yml
git add action.yml
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "Add generated action.yml 🤖"
if [[ '${{ github.ref_type }}' == 'tag' ]]; then
echo "Pushing tag ${{ github.ref_name }}"
git tag -f ${{ github.ref_name }}
git push -f origin ${{ github.ref_name }}
else
echo "Pushing branch ${{ github.ref_name }}"
git push origin ${{ github.ref_name }}
fi
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
if: github.ref_name == 'main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/release-new-action-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release new action version
on:
release:
types: [edited]
workflow_dispatch:
inputs:
TAG_NAME:
description: 'Tag name that the major tag will point to'
required: true

env:
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
verify_release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Grep action.yaml content
id: grep-image-content
run: |
image=$(grep -E "jekyll-build-pages.*\'" action.yml)
echo "::set-output name=image::$image"
- uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ steps.grep-image-content.outputs.image }}
regex: "jekyll-build-pages:(.*)'"
- name: Version match
run: |
if [ "${{ steps.regex-match.outputs.group1 }}" != "${{ env.TAG_NAME }}" ]; then
echo "version mismatch. action.yaml with version ${{ steps.regex-match.outputs.group1 }} Tag version ${{ env.TAG_NAME }}";
exit 1
fi
- name: Verify image published
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }}
update_tag:
needs: verify_release
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
environment:
name: releaseNewActionVersion
runs-on: ubuntu-latest
outputs:
major_tag: ${{ steps.update-major-tag.outputs.major-tag }}
steps:
- name: Update the ${{ env.TAG_NAME }} tag
id: update-major-tag
uses: actions/publish-action@v0.1.0
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
95 changes: 65 additions & 30 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,45 @@ on:
pull_request:
paths-ignore:
- 'README.md'
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
resolve-image-tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.regex-match.outputs.group1 }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: grep action.yaml content
id: grep-image-content
run: |
image=$(grep -E "jekyll-build-pages.*\'" action.yml)
echo "::set-output name=image::$image"
- uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ steps.grep-image-content.outputs.image }}
regex: "jekyll-build-pages:(.*)'"

test-simple:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: simple
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Render Action Metadata
run: |
./bin/render_action_metadata Dockerfile > action.yml
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
Expand All @@ -37,17 +62,19 @@ jobs:
path: ./test_projects/${{ env.TEST_NAME }}

test-readme:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: readme
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Render Action Metadata
run: |
./bin/render_action_metadata Dockerfile > action.yml
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
Expand All @@ -62,17 +89,19 @@ jobs:
path: ./test_projects/${{ env.TEST_NAME }}

test-octicons:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: octicons
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Render Action Metadata
run: |
./bin/render_action_metadata Dockerfile > action.yml
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
Expand All @@ -87,17 +116,19 @@ jobs:
path: ./test_projects/${{ env.TEST_NAME }}

test-mojombo:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: mojombo
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Render Action Metadata
run: |
./bin/render_action_metadata Dockerfile > action.yml
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
Expand All @@ -112,17 +143,19 @@ jobs:
path: ./test_projects/${{ env.TEST_NAME }}

test-themes:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: themes
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Render Action Metadata
run: |
./bin/render_action_metadata Dockerfile > action.yml
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
Expand All @@ -137,17 +170,19 @@ jobs:
path: ./test_projects/${{ env.TEST_NAME }}

test-jekyll-include-cache:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: jekyll-include-cache
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Render Action Metadata
run: |
./bin/render_action_metadata Dockerfile > action.yml
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
Expand Down
32 changes: 0 additions & 32 deletions action.yml.erb

This file was deleted.

Loading

0 comments on commit 0c8c980

Please sign in to comment.