Skip to content

Commit

Permalink
Merge pull request #21 from yorifuji/develop
Browse files Browse the repository at this point in the history
refactoring
  • Loading branch information
yorifuji authored Dec 2, 2023
2 parents c7bdae5 + 20534be commit ec848ac
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 72 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version: 2
enable-beta-ecosystems: true
updates:
- package-ecosystem: "github-actions"
directory: "/"
Expand Down
63 changes: 1 addition & 62 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,71 +27,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/github-script@v7
- uses: yorifuji/next-latest-release@v1
id: next-release
env:
bump: ${{ inputs.bump }}
with:
script: |
const { bump } = process.env
console.log(`Bumping ${bump} version`);
function log(message) {
console.log(message);
}
function logError(error) {
console.error('Error:', error);
core.setFailed(error);
}
let latestRelease;
try {
const result = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
latestRelease = result.data.tag_name;
log(`Latest release: ${latestRelease}`);
}
catch (error) {
logError(`Failed to get latest release: ${error.message}`);
return;
}
function bumpVersion(version, bump) {
const hasPrefix = version.startsWith('v');
const strippedVersion = hasPrefix ? version.substring(1) : version;
let [major, minor, patch] = strippedVersion.split('.').map(num => parseInt(num, 10));
switch (bump) {
case 'major':
major += 1;
minor = 0;
patch = 0;
break;
case 'minor':
minor += 1;
patch = 0;
break;
case 'patch':
patch += 1;
break;
default:
throw new Error('Invalid bump type');
}
return hasPrefix ? `v${major}.${minor}.${patch}` : `${major}.${minor}.${patch}`;
}
const nextVersion = bumpVersion(latestRelease, bump);
log(`Next release: ${nextVersion}`);
const nextVersionMajor = nextVersion.substring(0, nextVersion.indexOf('.'));
log(`Next release major: ${nextVersionMajor}`);
core.setOutput('version', nextVersion);
core.setOutput('major', nextVersionMajor);

- name: Create release
env:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: test

run-name: test

on: pull_request

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4

- run: touch foo

- uses: ./
with:
analyze_log: foo
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<img width="800" src="https://github.com/yorifuji/flutter-analyze-commenter/assets/583917/588272c1-f2d3-4b8d-be3e-20812caa42f4">

# Flutter Analyze Commenter

Flutter Analyze Commenter is a GitHub Action that posts `flutter analyze` results as comments on pull requests.
Expand Down
19 changes: 12 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
name: "Flutter Analyze Commenter"

description: "Auto comment on PRs based on Flutter Analyze results"

author: "yorifuji"

branding:
icon: "code"
color: "blue"
icon: code
color: blue

inputs:
analyze_log:
description: "Path to the Flutter analyze log file"
required: true
verbose:
description: "Enable verbose logging"
required: false
default: "false"
default: false

runs:
using: "composite"
using: composite
steps:
- name: Comment on PR based on Flutter Analyze results
uses: actions/github-script@v7
- uses: actions/github-script@v7
if: ${{ github.event_name == 'pull_request' }}
env:
ANALYZE_LOG: ${{ inputs.analyze_log }}
VERBOSE: ${{ inputs.verbose }}
if: ${{ github.event_name == 'pull_request' }}
with:
retries: 3
script: |
const analyzeLog = process.env.ANALYZE_LOG;
const verboseLogging = process.env.VERBOSE === 'true';
Expand Down

0 comments on commit ec848ac

Please sign in to comment.