Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
.idea
coverage
dist
lib
node_modules
*.log
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

26 changes: 0 additions & 26 deletions .eslintrc.json

This file was deleted.

33 changes: 17 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 'CI'

on:
pull_request:
push:
branches-ignore:
- master
Expand All @@ -10,22 +11,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Use Node.js 24
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}

- name: Cache dependencies
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
node-version-file: .nvmrc
cache: npm

- name: Install dependencies
run: npm ci
Expand All @@ -36,5 +28,14 @@ jobs:
- name: Check types
run: npm run typecheck

- name: Run unit tests
run: npm test
- name: Run unit and end-to-end tests
run: npm test && npm run test:e2e

- name: Audit production dependencies
run: npm run audit:prod

- name: Build and package action
run: npm run build && npm run package

- name: Build Docker action
run: docker build .
24 changes: 15 additions & 9 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v6

- name: Use Node.js 24
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: npm

- name: Install dependencies
run: npm ci

Expand All @@ -20,17 +26,17 @@ jobs:
run: npm run typecheck

- name: Run tests
run: npm run test:coverage
run: npm run test:coverage && npm run test:e2e

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
yml: codecov.yml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Audit production dependencies
run: npm run audit:prod

- name: Ensure build & shrinkwrap work
run: npm run build && npm run package

- name: Build Docker action
run: docker build .

- name: Bump version
id: bump_version
uses: 'phips28/gh-action-bump-version@master'
Expand All @@ -48,4 +54,4 @@ jobs:
tag_name: ${{ steps.bump_version.outputs.newTag }}
release_name: ${{ steps.bump_version.outputs.newTag }}
draft: false
prerelease: false
prerelease: false
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint && npm run format
3 changes: 0 additions & 3 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test && npm run typecheck
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
24
22 changes: 13 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
FROM node:14.21-slim
FROM node:24-slim

LABEL "com.github.actions.name"="Automated version bump for Android apps."
LABEL "com.github.actions.description"="Automated version bump for Android apps."
LABEL "com.github.actions.icon"="chevron-up"
LABEL "com.github.actions.color"="blue"

RUN apt-get update
RUN apt-get install -y git
RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*

COPY . .
WORKDIR /action

COPY package.json package-lock.json ./
RUN HUSKY=0 npm ci

RUN npm ci
RUN npm run build
RUN npm run package
RUN npm prune --production
COPY . .
RUN npm run build \
&& npm run package \
&& npm prune --omit=dev

ENTRYPOINT ["node", "/dist/index.js"]
ENTRYPOINT ["node", "/action/dist/index.js"]
11 changes: 0 additions & 11 deletions codecov.yml

This file was deleted.

169 changes: 169 additions & 0 deletions e2e/action.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import fs from 'fs';
import path from 'path';
import {
ActionFixture,
cleanupFixture,
gitInRemote,
gitInWorkspace,
readOutput,
runActionFixture,
} from './harness';

describe('packaged action with local git repositories', () => {
const fixtures: ActionFixture[] = [];
const run = (
options?: Parameters<typeof runActionFixture>[0],
): ActionFixture => {
const fixture = runActionFixture(options);
fixtures.push(fixture);
return fixture;
};

afterEach(() => {
fixtures.splice(0).forEach(cleanupFixture);
});

it('creates the initial version commit, tag, push, and output', () => {
const fixture = run({ unrelatedFile: true });
expect(fixture.result.status).toBe(0);
expect(gitInRemote(fixture, 'show', 'main:version.properties')).toBe(
[
'majorVersion=0',
'minorVersion=0',
'patchVersion=1',
'buildNumber=',
].join('\n'),
);
const remoteHead = gitInRemote(fixture, 'rev-parse', 'refs/heads/main');
expect(gitInRemote(fixture, 'rev-parse', 'refs/tags/0.0.1')).toBe(
remoteHead,
);
expect(gitInRemote(fixture, 'log', '-1', '--format=%s', 'main')).toBe(
'release: v0.0.1 [skip-ci]',
);
expect(readOutput(fixture)).toBe('new_tag=0.0.1');
expect(gitInWorkspace(fixture, 'status', '--porcelain')).toBe(
'?? notes.txt',
);
expect(
gitInRemote(
fixture,
'diff-tree',
'--no-commit-id',
'--name-only',
'-r',
'main',
),
).toBe('version.properties');
});

it.each([
['patch', ['fix: repair launch'], '1.2.4'],
['minor', ['feat: add login'], '1.3.0'],
[
'major precedence',
['fix: repair launch', 'feat: add login', 'refactor!: remove v1'],
'2.0.0',
],
])(
'performs a %s bump from the triggering commits',
(_, commits, version) => {
const fixture = run({ version: '1.2.3', commits });

expect(fixture.result.status).toBe(0);
expect(
gitInRemote(fixture, 'show', `${fixture.branch}:version.properties`),
).toBe(
[
`majorVersion=${version.split('.')[0]}`,
`minorVersion=${version.split('.')[1]}`,
`patchVersion=${version.split('.')[2]}`,
'buildNumber=',
].join('\n'),
);
expect(gitInRemote(fixture, 'rev-parse', `refs/tags/${version}`)).toBe(
gitInRemote(fixture, 'rev-parse', `refs/heads/${fixture.branch}`),
);
},
);

it('applies inputs, identity, and head-ref checkout', () => {
const fixture = run({
version: '1.2.3',
commits: ['feat: add login'],
headRef: 'feature/login',
inputs: {
tag_prefix: 'release-',
skip_ci: 'false',
build_number: '42',
commit_message: 'publish {{version}}',
},
environment: {
GITHUB_USER: 'Release Bot',
GITHUB_EMAIL: 'release@example.com',
},
});

expect(fixture.result.status).toBe(0);
expect(
gitInRemote(fixture, 'log', '-1', '--format=%s', fixture.branch),
).toBe('publish release-1.3.0.42');
expect(
gitInRemote(fixture, 'log', '-1', '--format=%an <%ae>', fixture.branch),
).toBe('Release Bot <release@example.com>');
expect(
gitInRemote(fixture, 'show', `${fixture.branch}:version.properties`),
).toContain('buildNumber=42');
expect(readOutput(fixture)).toBe('new_tag=1.3.0.42');
expect(gitInRemote(fixture, 'rev-parse', 'refs/heads/main')).not.toBe(
gitInRemote(fixture, 'rev-parse', `refs/heads/${fixture.branch}`),
);
});

it('reports a rejected push and leaves the remote unchanged', () => {
const fixture = run({
version: '1.2.3',
commits: ['fix: repair launch'],
rejectPush: true,
});

expect(fixture.result.status).toBe(1);
expect(gitInRemote(fixture, 'rev-parse', 'refs/heads/main')).toBe(
fixture.triggerSha,
);
expect(gitInRemote(fixture, 'tag', '--list', '1.2.4')).toBe('');
expect(gitInWorkspace(fixture, 'log', '-1', '--format=%s')).toBe(
'release: v1.2.4 [skip-ci]',
);
expect(gitInWorkspace(fixture, 'rev-parse', 'refs/tags/1.2.4')).toBe(
gitInWorkspace(fixture, 'rev-parse', 'HEAD'),
);
expect(readOutput(fixture)).toBe('');
expect(`${fixture.result.stdout}${fixture.result.stderr}`).toContain(
'rejected by e2e git shim',
);
});

it('reads commit messages from real GitHub push payload objects (#122)', () => {
const fixture = run({
version: '1.2.3',
commits: ['feat: add login'],
eventCommits: [{ id: 'fixture', message: 'feat: add login' }],
});

expect(fixture.result.status).toBe(0);
expect(gitInRemote(fixture, 'show', 'main:version.properties')).toContain(
'minorVersion=3',
);
});

it('keeps action output metadata mismatch documented for a later fix', () => {
const action = fs.readFileSync(
path.resolve(__dirname, '../action.yml'),
'utf8',
);

expect(action).toContain(' newTag:');
expect(action).not.toContain(' new_tag:');
});
});
Loading