Skip to content

Commit

Permalink
Merge branch 'alpha'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	package.json
  • Loading branch information
mario-jerkovic committed Nov 28, 2023
2 parents 6e0f3d8 + e4baffc commit 2f7b02c
Show file tree
Hide file tree
Showing 25 changed files with 7,671 additions and 5,946 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"ENOIMAGE",
"EDEPLOY",
"ENOAUTHENTICATION",
"ENOAUTHORIZATION"
"ENOAUTHORIZATION",
"tsup"
]
}
4 changes: 2 additions & 2 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module.exports = {
extends: [require.resolve('@rimac-technology/style-guide/eslint/core')],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
}
project: './tsconfig.lint.json',
},
}
12 changes: 6 additions & 6 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Lint and Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
Expand All @@ -29,15 +29,15 @@ jobs:
- run: yarn build
- uses: actions/upload-artifact@v3
with:
name: lib
path: lib/
name: dist
path: dist/
release:
name: Release
needs: build
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/alpha'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
Expand All @@ -49,8 +49,8 @@ jobs:
key: node_modules-${{ hashFiles('**/yarn.lock') }}
- uses: actions/download-artifact@v3
with:
name: lib
path: lib/
name: dist
path: dist/
- run: yarn release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ node_modules/
# Project
build/
lib/
dist/

# MacOS
.DS_Store
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
873 changes: 0 additions & 873 deletions .yarn/releases/yarn-3.5.0.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.2.cjs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
nodeLinker: node-modules
compressionLevel: mixed

enableGlobalCache: false

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.5.0.cjs
yarnPath: .yarn/releases/yarn-4.0.2.cjs
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
## [1.2.0](https://github.com/RimacTechnology/semantic-release-ecr/compare/v1.1.1...v1.2.0) (2023-04-18)
## [2.0.0-alpha.2](https://github.com/RimacTechnology/semantic-release-ecr/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) (2023-11-28)


### Bug Fixes

* set library type as "module" and export valid esm ([04ffb73](https://github.com/RimacTechnology/semantic-release-ecr/commit/04ffb73aacd754123d2f62100b61e7d989a32abb))


### Other

* update `semantic-release` config to use `cjs` extension ([b322e9e](https://github.com/RimacTechnology/semantic-release-ecr/commit/b322e9e60f3c140df6c05609a5b6a0a8cc7ac256))
* update all lint package to use `cjs` extension ([a31eb3a](https://github.com/RimacTechnology/semantic-release-ecr/commit/a31eb3a52d0fbef3d3c2515f332cb5e653b4c515))

## [2.0.0-alpha.1](https://github.com/RimacTechnology/semantic-release-ecr/compare/v1.1.1...v2.0.0-alpha.1) (2023-11-28)


### ⚠ BREAKING CHANGES

* ESM support

### Features

* replace soon to be deprecated aws-sdk v2 with v3 and update dependencies ([e53ae20](https://github.com/RimacTechnology/semantic-release-ecr/commit/e53ae207bcfdaa8b56d3f90c8c80c82620e7744d))
* update to latest v22 `semantic-release` ([a22b9c5](https://github.com/RimacTechnology/semantic-release-ecr/commit/a22b9c50591155f3a38f755b6fb8230b11c21395))

## [1.2.0-beta.1](https://github.com/RimacTechnology/semantic-release-ecr/compare/v1.1.1...v1.2.0-beta.1) (2023-04-18)

Expand Down
63 changes: 32 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rimac-technology/semantic-release-ecr",
"version": "1.2.0",
"version": "2.0.0-alpha.2",
"description": "Semantic-release plugin to publish a docker image to the AWS Elastic Container Registry",
"keywords": [
"release",
Expand All @@ -10,19 +10,21 @@
"repository": "[email protected]:RimacTechnology/semantic-release-ecr.git",
"license": "MIT",
"author": "Rimac Technology d.o.o.",
"main": "lib/index.js",
"type": "module",
"main": "dist/index.js",
"files": [
"lib"
"dist"
],
"scripts": {
"build": "tsc",
"build": "tsup",
"cm": "cz",
"postinstall": "husky install",
"lint": "yarn lint:eslint & yarn lint:prettier & yarn lint:package-json yarn lint:cspell",
"lint:cspell": "cspell --no-progress --no-summary '**'",
"lint:eslint": "eslint './src/**/*' --quiet --cache --cache-strategy content --cache-location '.eslintcache/'",
"lint:package-json": "npmPkgJsonLint --configFile ./.packagerc.js .",
"lint:prettier": "prettier --loglevel warn --no-editorconfig --no-error-on-unmatched-pattern --check \"./**/*{yaml,yml,json,md}\"",
"lint": "yarn lint:cspell && yarn lint:prettier && yarn lint:package-json && yarn lint:eslint",
"lint:cspell": "cspell --no-progress --unique --no-summary '**'",
"lint:eslint": "eslint './src' --quiet --cache",
"lint:fix": "yarn lint:prettier --write && yarn lint:eslint --fix",
"lint:package-json": "npmPkgJsonLint --configFile .packagerc.cjs .",
"lint:prettier": "prettier --log-level warn --check './**/*{yaml,yml,json,md,graphql}'",
"prepack": "pinst --disable",
"postpack": "pinst --enable",
"release": "semantic-release"
Expand All @@ -38,39 +40,38 @@
}
},
"dependencies": {
"@aws-sdk/client-ecr": "^3.315.0",
"aggregate-error": "^3.1.0"
"@aws-sdk/client-ecr": "^3.460.0",
"aggregate-error": "^5.0.0"
},
"devDependencies": {
"@commitlint/cli": "^17.6.1",
"@commitlint/config-conventional": "^17.6.1",
"@rimac-technology/style-guide": "^7.0.0",
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@rimac-technology/style-guide": "^9.2.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/commit-analyzer": "^11.1.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.7",
"@semantic-release/npm": "^9.0.2",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/node": "^18.15.11",
"@types/semantic-release": "^17.2.6",
"@semantic-release/github": "^9.2.3",
"@semantic-release/npm": "^11.0.1",
"@semantic-release/release-notes-generator": "^12.1.0",
"@types/node": "^20.10.0",
"commitizen": "^4.3.0",
"conventional-changelog-conventionalcommits": "^5.0.0",
"cspell": "^6.31.1",
"eslint": "^8.38.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
"cspell": "^8.0.0",
"eslint": "^8.54.0",
"husky": "^8.0.3",
"npm-package-json-lint": "^6.4.0",
"npm-package-json-lint": "^7.1.0",
"pinst": "^3.0.0",
"prettier": "^2.8.7",
"semantic-release": "^19.0.5",
"typescript": "^5.0.4"
"prettier": "^3.1.0",
"semantic-release": "^22.0.8",
"tsup": "^8.0.1",
"typescript": "^5.3.2"
},
"peerDependencies": {
"semantic-release": ">=19.0.0"
"semantic-release": ">=20"
},
"packageManager": "yarn@3.5.0",
"packageManager": "yarn@4.0.2",
"engines": {
"node": ">=16.14",
"yarn": ">=3"
"node": ">=22"
},
"publishConfig": {
"access": "public"
Expand Down
22 changes: 14 additions & 8 deletions src/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import {
GetAuthorizationTokenCommand,
} from '@aws-sdk/client-ecr'
import AggregateError from 'aggregate-error'
import type { Context } from 'semantic-release'
import type { VerifyConditionsContext } from 'semantic-release'

import type {
AWSConfig,
AWSLoginValue,
AWSConfigType,
AWSLoginValueType,
} from './aws.types'
import { getError } from './error'

export class AWS {
public static loadConfig(context: Context): AWSConfig {
public static loadConfig(context: VerifyConditionsContext): AWSConfigType {
let region: string | null = null
let accessKeyId: string | null = null
let secretAccessKey: string | null = null
Expand Down Expand Up @@ -50,17 +50,19 @@ export class AWS {
})
}

public async login(): Promise<AWSLoginValue> {
public async login(): Promise<AWSLoginValueType> {
const { authorizationData } = await this.awsEcr.send(new GetAuthorizationTokenCommand({}))

if (!authorizationData?.length) {
const [authorization] = authorizationData ?? []

if (!authorization) {
throw new AggregateError([getError('ENOAUTHORIZATION')])
}

const [{
const {
authorizationToken,
proxyEndpoint,
}] = authorizationData
} = authorization

if (!authorizationToken || !proxyEndpoint) {
throw new AggregateError([getError('ENOAUTHORIZATION')])
Expand All @@ -70,6 +72,10 @@ export class AWS {
.toString('utf-8')
.split(':')

if (!username || !password) {
throw new AggregateError([getError('ENOAUTHORIZATION')])
}

return {
password,
registry: proxyEndpoint,
Expand Down
4 changes: 2 additions & 2 deletions src/aws.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type AWSConfig = {
export type AWSConfigType = {
/**
* AWS access key id
*
Expand All @@ -19,7 +19,7 @@ export type AWSConfig = {
secretAccessKey: string | null
}

export type AWSLoginValue = {
export type AWSLoginValueType = {
/**
* Password value decoded from authorization token
* Documentation: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecr/get-authorization-token.html#output
Expand Down
18 changes: 7 additions & 11 deletions src/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,24 @@ import {
} from 'child_process'

import AggregateError from 'aggregate-error'
import type { Context } from 'semantic-release'
import type { PublishContext } from 'semantic-release'

import type {
DockerConfig,
DockerImage,
DockerConfigType,
DockerImageType,
} from './docker.types'
import { getError } from './error'
import type { PluginConfig } from './types'

export class Docker {
public static loadConfig(pluginConfig: PluginConfig, context: Context): DockerConfig {
public static loadConfig(pluginConfig: PluginConfig, context: PublishContext): DockerConfigType {
const tags: string[] = []
const rawTags: string[] = []
const rawTags: string[] = [context.nextRelease.version]

if (pluginConfig.tags) {
rawTags.push(...pluginConfig.tags)
}

if (context.nextRelease) {
rawTags.push(context.nextRelease.version)
}

for (const rawTag of rawTags) {
const tag = rawTag.startsWith('$') ? context.env[rawTag.slice(1)] : rawTag

Expand Down Expand Up @@ -105,7 +101,7 @@ export class Docker {
return true
}

private getImage(name: string): DockerImage | undefined {
private getImage(name: string): DockerImageType | undefined {
const stdout = execSync('docker images --format "{{json . }}"')
.toString('utf-8')
.match(/.+/gu)
Expand All @@ -115,7 +111,7 @@ export class Docker {
}

return stdout
.map<DockerImage>((value) => JSON.parse(value))
.map<DockerImageType>((value) => JSON.parse(value))
.find((image) => image.Repository === name)
}
}
4 changes: 2 additions & 2 deletions src/docker.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type DockerConfig = {
export type DockerConfigType = {
/**
* The name of the image to push to the ECR
*
Expand All @@ -13,7 +13,7 @@ export type DockerConfig = {
imageTags: string[]
}

export type DockerImage = {
export type DockerImageType = {
/**
* Docker image ID
*
Expand Down
4 changes: 2 additions & 2 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SemanticReleaseError extends Error {
}
}

type ErrorCodes =
type ErrorCodesType =
| 'EBUILD'
| 'EDEPLOY'
| 'ENOACCESSKEYID'
Expand All @@ -28,7 +28,7 @@ type ErrorCodes =
| 'ENOREGION'
| 'ENOSECRETACCESSKEY'

export function getError(code: ErrorCodes): SemanticReleaseError {
export function getError(code: ErrorCodesType): SemanticReleaseError {
switch (code) {
case 'ENOACCESSKEYID': {
return new SemanticReleaseError(
Expand Down
4 changes: 2 additions & 2 deletions src/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import AggregateError from 'aggregate-error'
import type { Context } from 'semantic-release'
import type { PrepareContext } from 'semantic-release'

import { Docker } from './docker'
import { getError } from './error'
import type { PluginConfig } from './types'

export async function prepare(pluginConfig: PluginConfig, context: Context): Promise<void> {
export async function prepare(pluginConfig: PluginConfig, context: PrepareContext): Promise<void> {
if (!pluginConfig.buildImage) {
context.logger.log('No "buildImage" command provided, skipping prepare step')

Expand Down
Loading

0 comments on commit 2f7b02c

Please sign in to comment.