Skip to content

Commit 44f62ea

Browse files
authored
Merge pull request #80 from RobotsAndPencils/onepassword-upgrade
Upgrade to OnePassword 2.30.0
2 parents d09c8fb + 5c44234 commit 44f62ea

File tree

9 files changed

+98
-97
lines changed

9 files changed

+98
-97
lines changed

Diff for: .github/workflows/test.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
npm install
1717
- run: |
1818
npm run all
19-
test: # make sure the action works on a clean machine without building
19+
test: # make sure the action works
2020
strategy:
2121
matrix:
2222
runs-on: [macos-latest, ubuntu-20.04, ubuntu-22.04, ubuntu-latest]
@@ -30,6 +30,10 @@ jobs:
3030
- name: Checkout Github
3131
uses: actions/checkout@v3
3232
if: ${{ !env.ACT }}
33+
- name: Install dependencies
34+
run: npm install
35+
- name: Build Typescript
36+
run: npm run all
3337
- name: Test Action
3438
uses: ./
3539
id: secrets

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.0.0
2+
3+
- Migrated from 1Password CLI version 1.8.0 to 2.30.0
4+
15
## 2.1.0
26

37
- Support for multi word names. Resolves [#54](https://github.com/RobotsAndPencils/1password-action/issues/54)

Diff for: __tests__/parsing.test.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,19 @@ test('parses multiple unquoted, renamed items', async () => {
4242
})
4343

4444
test('parses single unquoted multi word item', async () => {
45-
const output = parseItemRequestsInput('GitHub Action Test Vault > Test Login Four Words')
45+
const output = parseItemRequestsInput(
46+
'GitHub Action Test Vault > Test Login Four Words'
47+
)
4648
expect(output).toHaveLength(1)
4749
expect(output[0].vault).toBe('GitHub Action Test Vault')
4850
expect(output[0].name).toBe('Test Login Four Words')
4951
expect(output[0].outputName).toBe('test_login_four_words')
5052
})
5153

5254
test('parses single unquoted multi word item separated by periods', async () => {
53-
const output = parseItemRequestsInput('GitHub Action Test Vault > Test.Login.Four.Words')
55+
const output = parseItemRequestsInput(
56+
'GitHub Action Test Vault > Test.Login.Four.Words'
57+
)
5458
expect(output).toHaveLength(1)
5559
expect(output[0].vault).toBe('GitHub Action Test Vault')
5660
expect(output[0].name).toBe('Test.Login.Four.Words')

Diff for: dist/index.js

+23-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/1password.ts

+24-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {install} from './install'
33
import * as tc from '@actions/tool-cache'
44
import {execWithOutput} from './exec'
55

6-
const ONE_PASSWORD_VERSION = '1.8.0'
6+
const ONE_PASSWORD_VERSION = '2.30.0'
77

88
export class OnePassword {
99
onePasswordEnv: {[key: string]: string}
@@ -37,13 +37,18 @@ export class OnePassword {
3737
const output = await execWithOutput(
3838
'op',
3939
[
40-
'signin',
40+
'account',
41+
'add',
42+
'--address',
4143
signInAddress,
44+
'--email',
4245
emailAddress,
46+
'--secret-key',
4347
secretKey,
4448
'--raw',
4549
'--shorthand',
46-
'github_action'
50+
'github_action',
51+
'--signin'
4752
],
4853
{
4954
env,
@@ -67,23 +72,31 @@ export class OnePassword {
6772
async listItemsInVault(vault: string): Promise<string> {
6873
const env = this.onePasswordEnv
6974

70-
return await execWithOutput('op', ['list', 'items', '--vault', vault], {
71-
env
72-
})
75+
return await execWithOutput(
76+
'op',
77+
['item', 'list', '--vault', vault, '--format=json'],
78+
{
79+
env
80+
}
81+
)
7382
}
7483

7584
async getItemInVault(vault: string, uuid: string): Promise<string> {
7685
const env = this.onePasswordEnv
77-
return await execWithOutput('op', ['get', 'item', uuid, '--vault', vault], {
78-
env
79-
})
86+
return await execWithOutput(
87+
'op',
88+
['item', 'get', uuid, '--vault', vault, '--format=json'],
89+
{
90+
env
91+
}
92+
)
8093
}
8194

8295
async getDocument(uuid: string, filename: string): Promise<void> {
8396
const env = this.onePasswordEnv
8497
await execWithOutput(
8598
'op',
86-
['get', 'document', uuid, '--output', filename],
99+
['document', 'get', uuid, '--output', filename],
87100
{
88101
env
89102
}
@@ -92,6 +105,6 @@ export class OnePassword {
92105

93106
async signOut(): Promise<void> {
94107
const env = this.onePasswordEnv
95-
await execWithOutput('op', ['signout', '--forget'], {env})
108+
await execWithOutput('op', ['signout', '--account', 'github_action', '--forget'], {env})
96109
}
97110
}

Diff for: src/install.ts

+6-30
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,24 @@ import {mv} from '@actions/io'
44
import {chmod} from '@actions/io/lib/io-util'
55
import * as tc from '@actions/tool-cache'
66
import * as exec from '@actions/exec'
7-
import {execWithOutput} from './exec'
87

9-
const CERT_IDENTIFIER = 'Developer ID Installer: AgileBits Inc. (2BUA8C4S2C)'
108
const KEY_FINGERPRINT = '3FEF9748469ADBE15DA7CA80AC2D62742012EA22'
119

1210
export async function install(onePasswordVersion: string): Promise<void> {
1311
const platform = os.platform().toLowerCase()
1412

15-
let extension = 'zip'
13+
let arch = 'amd64'
1614
if (platform === 'darwin') {
17-
extension = 'pkg'
15+
arch = 'arm64'
1816
}
19-
const onePasswordUrl = `https://cache.agilebits.com/dist/1P/op/pkg/v${onePasswordVersion}/op_${platform}_amd64_v${onePasswordVersion}.${extension}`
20-
const archive = await tc.downloadTool(onePasswordUrl)
17+
const onePasswordUrl = `https://cache.agilebits.com/dist/1P/op2/pkg/v${onePasswordVersion}/op_${platform}_${arch}_v${onePasswordVersion}.zip`
2118
core.info(
2219
`Downloading ${onePasswordVersion} for ${platform} from ${onePasswordUrl}`
2320
)
21+
const archive = await tc.downloadTool(onePasswordUrl)
22+
const extracted = await tc.extractZip(archive)
2423

25-
let extracted: string
26-
if (platform === 'darwin') {
27-
const signatureCheck = await execWithOutput('pkgutil', [
28-
'--check-signature',
29-
archive
30-
])
31-
if (signatureCheck.includes(CERT_IDENTIFIER) === false) {
32-
throw new Error(
33-
`Signature verification of the installer package downloaded from ${onePasswordUrl} failed.\nExpecting it to include ${CERT_IDENTIFIER}.\nReceived:\n${signatureCheck}`
34-
)
35-
} else {
36-
core.info('Verified the code signature of the installer package.')
37-
}
38-
39-
// Expanding the package manually to avoid needing an admin password for installation and to be able to put it into the tool cache.
40-
const destination = 'op.unpkg'
41-
await exec.exec('pkgutil', ['--expand', archive, destination])
42-
await exec.exec(
43-
`/bin/bash -c "cat ${destination}/Payload | gzip -d | cpio -id"`
44-
)
45-
extracted = '.'
46-
} else {
47-
extracted = await tc.extractZip(archive)
48-
24+
if (platform !== 'darwin') {
4925
await exec.exec('gpg', [
5026
'--keyserver',
5127
'keyserver.ubuntu.com',

0 commit comments

Comments
 (0)