v3.4.1 #90
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update release version. | |
on: | |
release: | |
types: [published] | |
jobs: | |
check-version: | |
runs-on: ubuntu-latest | |
name: semver-diff | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v8 | |
- name: Run semver-diff | |
id: semver-diff | |
uses: tj-actions/semver-diff@v2 | |
- name: Show release type | |
if: steps.semver-diff.outputs.release_type == 'major' | |
run: | | |
OLD_VERSION=$(echo "${{ steps.semver-diff.outputs.old_version }}" | cut -d'.' -f1 | cut -d'v' -f2) | |
MAJOR_VERSION=$(echo "${{ steps.semver-diff.outputs.new_version }}" | cut -d'.' -f1 | cut -d'v' -f2) | |
make upgrade-from-one-version-to-a-major-version OLD_VERSION=$OLD_VERSION MAJOR_VERSION=$MAJOR_VERSION | |
- name: Commit the change to the main branch and update the latest version | |
if: steps.semver-diff.outputs.release_type == 'major' | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git tag -d ${{ steps.branch-name.outputs.tag }} | |
git add . | |
git commit -m "chore: upgraded from ${{ steps.semver-diff.outputs.old_version }} -> ${{ steps.semver-diff.outputs.new_version }}" | |
git push -f origin main | |
git tag ${{ steps.branch-name.outputs.tag }} | |
git push -f origin ${{ steps.branch-name.outputs.tag }} | |
release: | |
name: release | |
runs-on: ubuntu-latest | |
needs: check-version | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
update-version: | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: Sync release version. | |
uses: tj-actions/sync-release-version@v13 | |
id: sync-release-version | |
with: | |
pattern: '${{ github.repository }}@' | |
only_major: true | |
paths: | | |
README.md | |
- name: Sync release version for action.yml. | |
uses: tj-actions/sync-release-version@v13 | |
id: sync-release-version-action | |
with: | |
pattern: 'version: ' | |
paths: | | |
action.yml | |
- name: Run git-cliff | |
uses: tj-actions/git-cliff@v1 | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v8 | |
- name: Verify Changed files | |
uses: tj-actions/verify-changed-files@v17 | |
id: verify-changed-files | |
with: | |
files: | | |
README.md | |
HISTORY.md | |
action.yml | |
- name: Commit changes | |
if: steps.verify-changed-files.outputs.files_changed == 'true' | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git tag -d ${{ steps.branch-name.outputs.tag }} | |
git add ${{ steps.verify-changed-files.outputs.changed_files }} | |
git commit -m "chore: upgraded from ${{ steps.sync-release-version.outputs.old_version }} -> ${{ steps.sync-release-version.outputs.new_version }}" | |
git tag ${{ steps.branch-name.outputs.tag }} | |
git push -f origin ${{ steps.branch-name.outputs.tag }} | |
- name: Run release-tagger | |
uses: tj-actions/release-tagger@v4 | |
with: | |
token: ${{ secrets.PAT_TOKEN }} | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5.0.2 | |
with: | |
base: "main" | |
labels: "merge when passing" | |
title: "Upgraded to ${{ steps.sync-release-version.outputs.new_version }}" | |
branch: "upgrade-to-${{ steps.sync-release-version.outputs.new_version }}" | |
commit-message: "Upgraded from ${{ steps.sync-release-version.outputs.old_version }} -> ${{ steps.sync-release-version.outputs.new_version }}" | |
body: "View [CHANGES](https://github.com/${{ github.repository }}/compare/${{ steps.sync-release-version.outputs.old_version }}...${{ steps.sync-release-version.outputs.new_version }})" | |
token: ${{ secrets.PAT_TOKEN }} |