Skip to content

Commit

Permalink
ci: 最新のtagを取得するアクションをまとめる
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucky3028 committed Dec 31, 2022
1 parent 5c067c7 commit 8dd91a7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
15 changes: 15 additions & 0 deletions .github/actions/output-latest-tag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Output latest git tag
description: Output latest git tag
outputs:
latest-tag:
description: latest git tag
value: ${{ steps.latest-tag.outputs.new-ver }}
runs:
using: composite
steps:
- name: Output tag
id: latest-tag
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "new-ver=$LATEST_TAG" >> $GITHUB_OUTPUT
shell: bash
12 changes: 5 additions & 7 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout latest release tag
id: new-ver
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $LATEST_TAG
echo "new-ver=$LATEST_TAG" >> $GITHUB_OUTPUT
- uses: ./.github/actions/output-latest-tag
id: latest-tag
- name: Checkout a latest tag
run: git checkout ${{ steps.latest-tag.outputs.latest-tag }}
- name: Download jar
uses: actions/download-artifact@v3
with:
name: jar
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.new-ver.outputs.new-ver }}
tag_name: ${{ steps.latest-tag.outputs.latest-tag }}
files: ./*.jar
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Fetch and checkout again
run: |
git fetch --prune --tags --unshallow
git checkout $(git describe --tags --abbrev=0)
with:
fetch-depth: 0
- uses: ./.github/actions/output-latest-tag
id: latest-tag
- name: Checkout a latest tag
run: git checkout ${{ steps.latest-tag.outputs.latest-tag }}
- name: Setup Java & Gradle
uses: ./.github/actions/setup
- name: Build with Gradle
Expand Down

0 comments on commit 8dd91a7

Please sign in to comment.