Skip to content

Commit

Permalink
add: リリース用Workflowを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
cffnpwr committed May 1, 2024
1 parent 4874360 commit a685873
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Publish Docker image (release)

on:
push:
branches:
- taiyme
release:
types:
- published
workflow_dispatch:

jobs:
Expand Down
155 changes: 155 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Make Release

on:
pull_request:
branches:
- release
types:
- labeled

jobs:
check_actor:
name: Check release actor
runs-on: ubuntu-latest
steps:
- if: github.actor != github.repository_owner
run: exit 1

get_new_version:
name: Get new version
runs-on: ubuntu-latest
needs:
- check_actor
outputs:
version: ${{ steps.new_version.outputs.NEW_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get latest tag
id: latest_tag
run: |
git fetch --prune --depth=1
echo "LATEST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Get base version
id: base_version
run: |
echo "PREV_BASE_VERSION=$(echo ${{ github.env.LATEST_TAG }} | cut -d- -f1)" >> $GITHUB_ENV
echo "NEXT_BASE_VERSION=$(jq -r package.json '.version' | cut -d '-' -f 1)" >> $GITHUB_ENV
- name: Reset revision
if: github.env.PREV_BASE_VERSION != github.env.NEXT_BASE_VERSION
run: echo "REVISION=0" >> $GITHUB_ENV

- name: Update revision
if: github.env.PREV_BASE_VERSION == github.env.NEXT_BASE_VERSION
run: echo "REVISION=$(($(echo ${{ github.env.LATEST_TAG }} | cut -d '-'' -f 2 | cut -d '.' -f 2) + 1))" >> $GITHUB_ENV

- name: Build new version
id: new_version
run: |
echo "NEW_VERSION=${{ github.env.NEXT_BASE_VERSION }}-taiyme.${{ github.env.REVISION }}" >> $GITHUB_OUTPUT
update_package_json:
name: Update package.json
runs-on: ubuntu-latest
needs:
- get_new_version
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Update package.json
run: jq '.version = "${{ needs.get_new_version.outputs.version }}"' "${{ github.workspace }}/package.json" --tab > tmp && mv tmp "${{ github.workspace }}/package.json"

- name: Upload package.json
uses: actions/upload-artifact@v3
with:
name: version_files
path: ${{ github.workspace }}/package.json

update_docker_compose_yml:
name: Update docker-compose.yml
runs-on: ubuntu-latest
needs:
- get_new_version
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Update docker-compose.yml
run: yq -r eval '.services.web.image = "ghcr.io/${{ github.repository }}:${{ needs.get_new_version.outputs.version }}"' -i "${{ github.workspace }}/docker-compose_example.yml"

- name: Upload docker-compose.yml
uses: actions/upload-artifact@v3
with:
name: version_files
path: ${{ github.workspace }}/docker-compose_example.yml

commit_tag_push:
name: Commit, Tag and Push
needs:
- get_new_version
- update_package_json
- update_docker_compose_yml
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Download files
uses: actions/download-artifact@v3
with:
name: version_files

- name: Check change
id: is_chnage
run: echo "is_change=$(git status -s | wc -l)" >> $GITHUB_OUTPUT

- name: Commit and Tag
if: steps.is_chnage.outputs.is_change != '0'
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git add .
git commit --author=. -m "${{ needs.get_new_version.outputs.version }}"
git tag "${{ needs.get_new_version.outputs.version }}"
git push origin HEAD --follow-tags
merge_pr:
name: Merge Pull request
needs:
- commit_tag_push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: merge PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
gh pr merge ${{ github.event.pull_request.number }} --merge
release:
name: Release
needs:
- get_new_version
- merge_pr
runs-on: ubuntu-latest
steps:
- name: Checkout release branch
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}

- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.get_new_version.outputs.version }}
body: ${{ github.event.pull_request.body }}
3 changes: 2 additions & 1 deletion docker-compose_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ version: "3"

services:
web:
build: .
# build: .
image: ghcr.io/taiyme/misskey:12.119.2-taiyme-v1.2.0
restart: always
links:
- db
Expand Down

0 comments on commit a685873

Please sign in to comment.