Compare commits
1 Commits
v1.1.0
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b60e4772d |
@@ -11,7 +11,6 @@
|
||||
"eslint-comments/no-use": "off",
|
||||
"import/no-namespace": "off",
|
||||
"no-unused-vars": "off",
|
||||
"i18n-text/no-en": "off",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
|
||||
"@typescript-eslint/no-require-imports": "error",
|
||||
|
||||
45
.github/workflows/semantic-tag.yml
vendored
45
.github/workflows/semantic-tag.yml
vendored
@@ -1,45 +0,0 @@
|
||||
name: Publish semantic tags
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Release with semantic tag like v1.0.3
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.release.tag_name }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
- run: npm install semver
|
||||
- name: Get versions
|
||||
uses: actions/github-script@v6
|
||||
id: batch
|
||||
env:
|
||||
TAG_NAME: ${{ github.event.release.tag_name }}
|
||||
with:
|
||||
script: |
|
||||
const semver = require('semver')
|
||||
const { TAG_NAME } = process.env
|
||||
return {
|
||||
minor: `v${semver.major(TAG_NAME).toString()}.${semver.minor(TAG_NAME).toString()}`,
|
||||
major: `v${semver.major(TAG_NAME).toString()}`
|
||||
}
|
||||
- run: |
|
||||
git tag -f "$MAJOR_VER"
|
||||
git tag -f "$MINOR_VER"
|
||||
git push origin -f "$MAJOR_VER"
|
||||
git push origin -f "$MINOR_VER"
|
||||
env:
|
||||
MAJOR_VER: ${{ fromJSON(steps.batch.outputs.result).major }}
|
||||
MINOR_VER: ${{ fromJSON(steps.batch.outputs.result).minor }}
|
||||
22
.github/workflows/test.yml
vendored
22
.github/workflows/test.yml
vendored
@@ -21,8 +21,6 @@ jobs:
|
||||
- run: |
|
||||
npm ci
|
||||
npm run all
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run semantic-release
|
||||
run: |
|
||||
npx semantic-release
|
||||
@@ -31,8 +29,6 @@ jobs:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
test: # make sure the action works on a clean machine without building
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./
|
||||
@@ -44,21 +40,3 @@ jobs:
|
||||
- uses: ./
|
||||
with:
|
||||
version: 'v2.4.1'
|
||||
- uses: ./
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
actionlint:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request
|
||||
permissions:
|
||||
contents: read
|
||||
checks: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: reviewdog/action-actionlint@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
reporter: github-pr-review
|
||||
|
||||
15
README.md
15
README.md
@@ -12,18 +12,7 @@ Add a step to your workflow like below:
|
||||
steps:
|
||||
- uses: KengoTODA/actions-setup-docker-compose@main
|
||||
with:
|
||||
version: '2.14.2' # the full version of `docker-compose` command
|
||||
version: '1.29.2'
|
||||
```
|
||||
|
||||
Or you can omit it then set a `GITHUB_TOKEN` environment variable, to use the latest released version:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: KengoTODA/actions-setup-docker-compose@main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
The 'latest release' here means [the most recent non-prerelease, non-draft release, sorted by the created_at attribute](https://octokit.github.io/rest.js/v19#repos-get-latest-release).
|
||||
|
||||
Note that the `GITHUB_TOKEN` should have [`contents: read` permission](https://docs.github.com/en/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#contents) to fetch data from the GitHub.com.
|
||||
The `version` parameter is required, specify the full version of `docker-compose` command.
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
import {install, runCommand} from '../src/install'
|
||||
import * as core from '@actions/core'
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals'
|
||||
import {expect, test} from '@jest/globals'
|
||||
|
||||
describe('runCommand', () => {
|
||||
it('runs a command and returns its stdout', async () => {
|
||||
const result = await runCommand('echo foo bar')
|
||||
expect(result).toBe('foo bar')
|
||||
})
|
||||
test('runCommand', async () => {
|
||||
const result = await runCommand('echo foo bar')
|
||||
expect(result).toBe('foo bar')
|
||||
})
|
||||
|
||||
describe('install', () => {
|
||||
const cases = ['1.29.1', '1.29.2', '2.2.3', 'v2.2.3', 'v2.10.2']
|
||||
test.each(cases)('can install version %p', async (version: string) => {
|
||||
const commandPath = await install(version)
|
||||
core.addPath(commandPath)
|
||||
const result = await runCommand('docker-compose version')
|
||||
expect(result).toContain(version)
|
||||
})
|
||||
it('can install latest version', async () => {
|
||||
const commandPath = await install('latest')
|
||||
core.addPath(commandPath)
|
||||
const result = await runCommand('docker-compose version')
|
||||
expect(result).not.toBeFalsy()
|
||||
})
|
||||
async function testVersion(version: string) {
|
||||
const commandPath = await install(version)
|
||||
core.addPath(commandPath)
|
||||
const result = await runCommand('docker-compose version')
|
||||
expect(result).toContain(version)
|
||||
}
|
||||
|
||||
test('Install the right version', async () => {
|
||||
await testVersion('1.29.1')
|
||||
await testVersion('1.29.2')
|
||||
await testVersion('2.2.3')
|
||||
await testVersion('v2.2.3')
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@ description: 'Automate download and set up process for docker-compose command'
|
||||
author: 'Kengo TODA <skypencil@gmail.com>'
|
||||
inputs:
|
||||
version:
|
||||
default: 'latest'
|
||||
required: true
|
||||
description: 'the version of docker-compose command'
|
||||
branding:
|
||||
color: blue
|
||||
|
||||
10252
dist/index.js
vendored
10252
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
4321
package-lock.json
generated
4321
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kengotoda/actions-setup-docker-compose",
|
||||
"version": "1.1.0",
|
||||
"version": "1.0.7",
|
||||
"description": "the GitHub Action setting up docker-compose command",
|
||||
"main": "lib/main.js",
|
||||
"private": false,
|
||||
@@ -30,21 +30,20 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.4.0",
|
||||
"@actions/exec": "^1.1.0",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@octokit/action": "^4.0.10"
|
||||
"@actions/tool-cache": "^1.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/exec": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/node": "^17.0.0",
|
||||
"@typescript-eslint/parser": "^5.3.0",
|
||||
"@vercel/ncc": "^0.36.0",
|
||||
"@vercel/ncc": "^0.33.0",
|
||||
"eslint": "^8.1.0",
|
||||
"eslint-plugin-github": "^4.3.3",
|
||||
"eslint-plugin-jest": "^27.0.1",
|
||||
"eslint-plugin-jest": "^26.0.0",
|
||||
"jest": "^27.0.6",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "2.8.1",
|
||||
"prettier": "2.6.2",
|
||||
"semantic-release": "^19.0.2",
|
||||
"ts-jest": "^27.0.3",
|
||||
"typescript": "^4.3.5"
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import {cacheFile, downloadTool} from '@actions/tool-cache'
|
||||
import {exec} from '@actions/exec'
|
||||
import * as core from '@actions/core'
|
||||
import {Octokit} from '@octokit/action'
|
||||
|
||||
export async function runCommand(command: string): Promise<string> {
|
||||
let output = ''
|
||||
@@ -36,20 +34,7 @@ async function installOnLinux(version: string): Promise<string> {
|
||||
return cachedPath
|
||||
}
|
||||
|
||||
async function findLatestVersion(): Promise<string> {
|
||||
const octokit = new Octokit()
|
||||
const response = await octokit.repos.getLatestRelease({
|
||||
owner: 'docker',
|
||||
repo: 'compose'
|
||||
})
|
||||
return response.data.tag_name
|
||||
}
|
||||
|
||||
export async function install(version: string): Promise<string> {
|
||||
if (version === 'latest') {
|
||||
version = await findLatestVersion()
|
||||
core.info(`Requested to use the latest version: ${version}`)
|
||||
}
|
||||
switch (process.platform) {
|
||||
case 'linux':
|
||||
return installOnLinux(version)
|
||||
|
||||
@@ -4,7 +4,7 @@ import {install} from './install'
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const version: string = core.getInput('version', {
|
||||
trimWhitespace: true
|
||||
required: true
|
||||
})
|
||||
const commandPath = await install(version)
|
||||
core.addPath(commandPath)
|
||||
|
||||
Reference in New Issue
Block a user