Skip to content

Commit d96ada7

Browse files
fix/pipeline (#916)
1 parent 7ae460a commit d96ada7

File tree

5 files changed

+118
-159
lines changed

5 files changed

+118
-159
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: 📞 Build binaries and create packages
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
pre-release:
7+
description: 'set to true if running a real pre-release'
8+
type: boolean
9+
required: true
10+
env:
11+
# Allows to fetch multiple private repo crates with different deploy keys.
12+
CARGO_NET_GIT_FETCH_WITH_CLI: true
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
name: Build and upload
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Give GitHub Actions access to private crates
23+
uses: webfactory/[email protected]
24+
with:
25+
ssh-private-key: |
26+
${{ secrets.CAOS_OAUTH_DEPLOY_KEY }}
27+
${{ secrets.CAOS_OPAMP_DEPLOY_KEY }}
28+
29+
- name: Set tag and skip_upload=false for pre-release
30+
if: ${{ inputs.pre-release}}
31+
run: |
32+
NEWRELIC_SUPER_AGENT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' super-agent/Cargo.toml)
33+
if [ "${NEWRELIC_SUPER_AGENT_VERSION}" != "${{ github.ref_name }}" ]; then
34+
echo "Package version specified in Cargo.toml (${NEWRELIC_SUPER_AGENT_VERSION}) differs from tag (${{ github.event.release.tag_name }}), exiting"
35+
exit 1
36+
fi
37+
echo TAG_NAME=${{ github.event.release.tag_name }} >> $GITHUB_ENV
38+
echo SKIP_UPLOAD=false >> $GITHUB_ENV
39+
40+
41+
- name: Set tag and skip_upload=true for testing
42+
if: ${{ ! inputs.pre-release }}
43+
run: |
44+
git tag 0.100.0
45+
echo TAG_NAME=0.100.0 >> $GITHUB_ENV
46+
echo SKIP_UPLOAD=true >> $GITHUB_ENV
47+
48+
- uses: actions/setup-go@v5
49+
with:
50+
go-version: "~1.20"
51+
check-latest: true
52+
53+
- name: Release packages with GoReleaser
54+
uses: goreleaser/goreleaser-action@v5
55+
with:
56+
distribution: goreleaser
57+
version: latest
58+
args: release --snapshot=${{ env.SKIP_UPLOAD }} --clean --debug --timeout 2h --parallelism 1
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
GPG_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
62+
GPG_PRIVATE_KEY_BASE64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }} # base64 encoded
63+
GPG_MAIL: '[email protected]'
64+
NR_RELEASE_TAG: ${{ env.TAG_NAME }}
65+
66+
- name: Upload assets to pipeline
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: built-binaries
70+
path: |
71+
./bin/*
72+
./dist/*
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
on:
2+
workflow_dispatch:
3+
4+
# See https://docs.github.com/en/actions/using-jobs/using-concurrency
5+
name: build-packages and image
6+
env:
7+
# Allows to fetch multiple private repo crates with different deploy keys.
8+
CARGO_NET_GIT_FETCH_WITH_CLI: true
9+
RUST_VERSION: 1.82.0
10+
jobs:
11+
build-packages:
12+
name: Build packages
13+
uses: ./.github/workflows/component_packages.yml
14+
with:
15+
pre-release: false
16+
secrets: inherit
17+
18+
build-image:
19+
name: Build image
20+
uses: ./.github/workflows/component_image.yml
21+
with:
22+
image-tag: ci
23+
push: false
24+
secrets: inherit

.github/workflows/on_demand_prerelease_linux.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/prerelease.yml

Lines changed: 12 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -11,67 +11,16 @@ env:
1111
# See https://docs.github.com/en/actions/using-jobs/using-concurrency
1212
name: pre-release
1313
jobs:
14-
build:
15-
runs-on: ubuntu-latest
16-
name: Build and upload / ${{ matrix.arch }}
17-
strategy:
18-
matrix:
19-
arch: [arm64, amd64]
20-
steps:
21-
- uses: actions/checkout@v4
22-
with:
23-
fetch-depth: 0
24-
25-
- name: Give GitHub Actions access to private crates
26-
uses: webfactory/[email protected]
27-
with:
28-
ssh-private-key: |
29-
${{ secrets.CAOS_OAUTH_DEPLOY_KEY }}
30-
${{ secrets.CAOS_OPAMP_DEPLOY_KEY }}
31-
32-
- name: Verify version matches tag
33-
run: |
34-
NEWRELIC_SUPER_AGENT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' super-agent/Cargo.toml)
35-
if [ "${NEWRELIC_SUPER_AGENT_VERSION}" != "${{ github.ref_name }}" ]; then
36-
echo "Package version specified in Cargo.toml (${NEWRELIC_SUPER_AGENT_VERSION}) differs from tag (${{ github.event.release.tag_name }}), exiting"
37-
exit 1
38-
fi
39-
40-
- uses: actions/setup-go@v5
41-
with:
42-
go-version: "~1.20"
43-
check-latest: true
44-
45-
- name: Build binaries with GoReleaser
46-
uses: goreleaser/goreleaser-action@v5
47-
with:
48-
distribution: goreleaser
49-
version: latest
50-
args: build --clean --debug --timeout 2h --single-target --parallelism 1
51-
env:
52-
ARCH: "${{ matrix.arch }}"
53-
GOARCH: "${{ matrix.arch }}"
54-
GOOS: linux
55-
56-
- name: Release packages with GoReleaser
57-
uses: goreleaser/goreleaser-action@v5
58-
with:
59-
distribution: goreleaser
60-
version: latest
61-
args: release --clean --debug --timeout 2h -f dist/config.yaml --parallelism 1
62-
env:
63-
ARCH: "${{ matrix.arch }}"
64-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65-
GPG_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
66-
GPG_PRIVATE_KEY_BASE64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }} # base64 encoded
67-
GPG_MAIL: "[email protected]"
68-
NR_RELEASE_TAG: ${{ github.event.release.tag_name }}
69-
70-
# TODO Should we check that the released version matches tag?
14+
build-packages:
15+
name: Build packages
16+
uses: ./.github/workflows/component_packages.yml
17+
with:
18+
pre-release: true
19+
secrets: inherit
7120

7221
container:
7322
name: Build and Push container image
74-
needs: [build]
23+
needs: [ build ]
7524
uses: ./.github/workflows/component_image.yml
7625
with:
7726
image-tag: ${{ github.event.release.tag_name }}-rc
@@ -80,7 +29,7 @@ jobs:
8029

8130
security-scan:
8231
name: Security scan
83-
needs: [container]
32+
needs: [ container ]
8433
uses: ./.github/workflows/component_image_security.yml
8534
with:
8635
image-tag: ${{ github.event.release.tag_name }}-rc
@@ -89,7 +38,7 @@ jobs:
8938
upload:
9039
runs-on: ubuntu-latest
9140
name: Upload to S3
92-
needs: [build]
41+
needs: [ build ]
9342
steps:
9443
- uses: actions/checkout@v4
9544
with:
@@ -166,15 +115,15 @@ jobs:
166115

167116
molecule-packaging-tests:
168117
uses: ./.github/workflows/component_molecule_packaging.yml
169-
needs: [upload]
118+
needs: [ upload ]
170119
with:
171120
TAG: ${{ github.event.inputs.tag || github.event.release.tag_name }}
172121
PACKAGE_NAME: "newrelic-super-agent"
173122
REPO_ENDPOINT: "http://nr-downloads-ohai-staging.s3-website-us-east-1.amazonaws.com/preview"
174123

175124
canaries:
176125
uses: ./.github/workflows/component_canaries.yml
177-
needs: [molecule-packaging-tests]
126+
needs: [ molecule-packaging-tests ]
178127
with:
179128
TAG: ${{ github.event.inputs.tag || github.event.release.tag_name }}
180129
secrets:
@@ -202,7 +151,7 @@ jobs:
202151

203152
notify-failure:
204153
if: ${{ always() && failure() }}
205-
needs: [canaries]
154+
needs: [ canaries ]
206155
runs-on: ubuntu-latest
207156
steps:
208157
- name: Notify failure via Slack

.github/workflows/push_pr_package.yml

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,26 @@
11
on:
2+
push:
3+
branches:
4+
- main
25
pull_request:
36
paths:
47
- ".github/**"
58
- "build/**"
69
- ".goreleaser.yml"
710

811
# See https://docs.github.com/en/actions/using-jobs/using-concurrency
9-
name: build-packages
12+
name: build-packages and image
1013
env:
1114
# Allows to fetch multiple private repo crates with different deploy keys.
1215
CARGO_NET_GIT_FETCH_WITH_CLI: true
1316
RUST_VERSION: 1.82.0
1417
jobs:
15-
build:
16-
runs-on: ubuntu-latest
17-
name: Build and upload / ${{ matrix.arch }}
18-
strategy:
19-
matrix:
20-
arch: [arm64, amd64]
21-
steps:
22-
- uses: actions/checkout@v4
23-
with:
24-
fetch-depth: 0
25-
26-
- name: Give GitHub Actions access to private crates
27-
uses: webfactory/[email protected]
28-
with:
29-
ssh-private-key: |
30-
${{ secrets.CAOS_OAUTH_DEPLOY_KEY }}
31-
${{ secrets.CAOS_OPAMP_DEPLOY_KEY }}
32-
33-
- name: Install Rust ${{ env.RUST_VERSION }}
34-
uses: dtolnay/rust-toolchain@master
35-
with:
36-
toolchain: ${{ env.RUST_VERSION }}
37-
38-
- name: Install cross-rs
39-
run: cargo install cross
40-
41-
- uses: actions/setup-go@v5
42-
with:
43-
go-version: "~1.20"
44-
check-latest: true
45-
46-
- name: Build binaries with GoReleaser
47-
uses: goreleaser/goreleaser-action@v5
48-
with:
49-
distribution: goreleaser
50-
version: latest
51-
args: build --snapshot --clean --debug --timeout 2h --single-target --parallelism 1
52-
env:
53-
ARCH: "${{ matrix.arch }}"
54-
GOARCH: "${{ matrix.arch }}"
55-
GOOS: linux
18+
build-packages:
19+
name: Build packages
20+
uses: ./.github/workflows/component_packages.yml
21+
with:
22+
pre-release: false
23+
secrets: inherit
5624

5725
build-image:
5826
name: Build image

0 commit comments

Comments
 (0)