Skip to content

Commit c3191f1

Browse files
committed
add assets upload-url to env
1 parent 53cbe9f commit c3191f1

File tree

6 files changed

+118
-59
lines changed

6 files changed

+118
-59
lines changed

CONTRIBUTION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ tbd ;)
22

33
## Installation
44

5-
The installation is needed only for contirbuting.
5+
git clone <this-repo>
66

7-
Go to your GOPATH under `src/` and run: `go get https://gitlab.com/eksrvb/awesome-ci-semver`
7+
to test against github-actions source the env-template `. ./tests/.env-template-github`
88

99
## How to test the software
1010

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
1111
## Usage
1212

13-
You can use this tool in your CI pipeline or locally on your command line. Just [download](https://github.com/eksrvb/awesome-ci/releases/latest/download/awesome-ci) the most recently released version and get started. You can find out how to integrate this into your respective pipeline in the following document. There are also several examples in the [examples section](https://eksrvb.github.io/awesome-ci/docs/examples) of the documentation. If an example is not included, please feel free to inquire about a related [issue](https://github.com/eksrvb/awesome-ci/issues/new/choose).
13+
You can use this tool in your CI pipeline or locally on your command line. Just [download](https://github.com/fullstack-devops/awesome-ci/releases/latest/download/awesome-ci) the most recently released version and get started. You can find out how to integrate this into your respective pipeline in the following document. There are also several examples in the [examples section](https://fullstack-devops.github.io/awesome-ci/docs/examples) of the documentation. If an example is not included, please feel free to inquire about a related [issue](https://github.com/fullstack-devops/awesome-ci/issues/new/choose).
1414

15-
If more functionality is needed you can just open a problem in this project and of course bugs can be fixed in the same way by filing a [bug report](https://github.com/eksrvb/awesome-ci/issues/new/choose).
15+
If more functionality is needed you can just open a problem in this project and of course bugs can be fixed in the same way by filing a [bug report](https://github.com/fullstack-devops/awesome-ci/issues/new/choose).
1616

17-
If you have any questions, you can find a form on the issue board. First, make sure your question is already in the [Questions and Answers](https://eksrvb.github.io/awesome-ci/docs/questions_and_answers) section before asking a question. You can find frequently asked questions there too.
17+
If you have any questions, you can find a form on the issue board. First, make sure your question is already in the [Questions and Answers](https://fullstack-devops.github.io/awesome-ci/docs/questions_and_answers) section before asking a question. You can find frequently asked questions there too.
1818

1919
## Documentation
2020

21-
[See the manual](https://eksrvb.github.io/awesome-ci/) for setup, usage instructions and a lot more. (the documentation is still rising)
21+
[See the manual](https://fullstack-devops.github.io/awesome-ci/) for setup, usage instructions and a lot more. (the documentation is still rising)
2222

2323
## Getting help
2424

docs/commands/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You can find out more about the subcommands by clicking on the relevant one in t
3131

3232
| Subcommand | Description |
3333
| ---------------------------------------------------------------------------------- | ------------------------------------------------------- |
34-
| [release](https://eksrvb.github.io/awesome-ci/commands/createRelease.html) | creates a release at GitHub or GitLab |
35-
| [pr](https://eksrvb.github.io/awesome-ci/commands/getBuildInfos.html) | prints out any git information and can manipulate these |
36-
| [parseJSON](https://eksrvb.github.io/awesome-ci/commands/parseJSON.html) | can parse simple JSON files |
37-
| [parseYAML](https://eksrvb.github.io/awesome-ci/commands/parseYAML.html) | can parse simple YAML files |
34+
| [release](https://fullstack-devops.github.io/awesome-ci/commands/createRelease.html) | creates a release at GitHub or GitLab |
35+
| [pr](https://fullstack-devops.github.io/awesome-ci/commands/getBuildInfos.html) | prints out any git information and can manipulate these |
36+
| [parseJSON](https://fullstack-devops.github.io/awesome-ci/commands/parseJSON.html) | can parse simple JSON files |
37+
| [parseYAML](https://fullstack-devops.github.io/awesome-ci/commands/parseYAML.html) | can parse simple YAML files |

docs/examples/github_actions.md

Lines changed: 81 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,64 +18,106 @@ nav_order: 1
1818
</details>
1919

2020

21-
### Build and publish npm packages
21+
### Build a Release
22+
23+
This is an example from th awesome-ci project you can find the original workflow [here](https://github.com/fullstack-devops/awesome-ci/blob/main/.github/workflows/Release.yaml)
24+
2225
```yaml
23-
name: Publish
26+
name: Publish Release
2427

2528
on:
2629
push:
27-
branches:
28-
- 'master'
30+
branches:
31+
- "main"
32+
paths-ignore:
33+
- "README.md"
34+
- 'docs/**'
35+
- '.github/ISSUE_TEMPLATE/**'
36+
- '.github/PULL_REQUEST_TEMPLATE.md'
37+
2938

3039
jobs:
31-
setup:
32-
runs-on: nodejs
40+
generate_infos:
41+
runs-on: ubuntu-latest
42+
outputs:
43+
releaseid: $\{\{ steps.tag.outputs.releaseid \}\}
44+
version: $\{\{ steps.tag.outputs.version \}\}
45+
pr: $\{\{ steps.tag.outputs.pr \}\}
3346
steps:
34-
- name: Checkout code
35-
uses: actions/checkout@v1
36-
- uses: eksrvb/awesome-ci@main
37-
- uses: actions/setup-node@v2
38-
with:
39-
node-version: '14.x'
40-
registry-url: 'https://registry.npmjs.org'
41-
- name: install npm packages
42-
run: npm install
43-
- name: package Applikation
44-
run: npm run build
45-
name: DryRun Release
46-
run: ./awesome-ci createRelease -publishNpm dist/my-project/
47+
- name: Check out the repo
48+
uses: actions/checkout@v2
49+
- name: Setup awesome-ci
50+
uses: fullstack-devops/awesome-ci-action@main
51+
52+
- name: collect infos and create release
53+
run: |
54+
awesome-ci pr info
55+
awesome-ci release create # making a draft
4756
env:
4857
GITHUB_TOKEN: $\{\{ secrets.GITHUB_TOKEN \}\}
49-
```
5058

51-
### Build and upload a go project
52-
```yaml
53-
name: Publish
59+
- name: collect infos
60+
id: tag
61+
shell: bash
62+
run: |
63+
echo "::set-output name=version::$ACI_VERSION"
64+
echo "::set-output name=pr::$ACI_PR"
65+
echo "::set-output name=releaseid::$ACI_RELEASE_ID"
5466
55-
on:
56-
push:
57-
branches:
58-
- 'master'
59-
60-
jobs:
6167
build:
6268
runs-on: ubuntu-latest
69+
needs: generate_infos
70+
strategy:
71+
matrix:
72+
arch: ["amd64", "arm64"]
6373
steps:
6474
- name: Checkout code
6575
uses: actions/checkout@v2
66-
- uses: eksrvb/awesome-ci@main
6776
- name: Set up Go
6877
uses: actions/setup-go@v2
6978
with:
70-
go-version: 1.15
71-
- name: set environment variables
72-
run: awesome-ci getBuildInfos
79+
go-version: 1.17
80+
81+
- name: Build "$\{\{ matrix.arch \}\}"
82+
run: go build -v -ldflags "-X main.version=$\{\{ needs.generate_infos.outputs.version \}\}" -o out/awesome-ci_$\{\{ needs.generate_infos.outputs.version \}\}_$\{\{ matrix.arch \}\}
7383
env:
74-
GITHUB_TOKEN: $\{\{ secrets.GITHUB_TOKEN \}\}
75-
- name: Build and write version to binary
76-
run: go build -v -ldflags "-X main.version=$NEXT_VERSION"
77-
- name: Create Release and upload
78-
run: ./awesome-ci createRelease -uploadArtifacts file=my-compiled-binary
84+
GOOS: linux
85+
GOARCH: "$\{\{ matrix.arch \}\}"
86+
87+
- name: Cache build outputs
88+
uses: actions/cache@v2
89+
env:
90+
cache-name: cache-outputs-modules
91+
with:
92+
path: out/
93+
key: awesome-ci-$\{\{ github.sha \}\}-$\{\{ hashFiles('out/awesome-ci*') \}\}
94+
restore-keys: |
95+
awesome-ci-$\{\{ github.sha \}\}
96+
97+
publish_release:
98+
runs-on: ubuntu-latest
99+
needs: [generate_infos, build]
100+
steps:
101+
- name: Checkout code
102+
uses: actions/checkout@v2
103+
- name: Setup awesome-ci
104+
uses: fullstack-devops/awesome-ci-action@main
105+
106+
- name: get cached build outputs
107+
uses: actions/cache@v2
108+
env:
109+
cache-name: cache-outputs-modules
110+
with:
111+
path: out/
112+
key: awesome-ci-$\{\{ github.sha \}\}
113+
114+
- name: Publish Release
115+
run: awesome-ci release publish -releaseid "$ACI_RELEASE_ID" -upload "file=out/$ARTIFACT1,file=out/$ARTIFACT2"
79116
env:
80117
GITHUB_TOKEN: $\{\{ secrets.GITHUB_TOKEN \}\}
81-
```
118+
ACI_RELEASE_ID: $\{\{ needs.generate_infos.outputs.releaseid \}\}
119+
ARTIFACT1: awesome-ci_$\{\{ needs.generate_infos.outputs.version \}\}_amd64
120+
ARTIFACT2: awesome-ci_$\{\{ needs.generate_infos.outputs.version \}\}_arm64
121+
```
122+
123+
You need more examples? Please open an issue!

src/acigithub/release.go

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,18 @@ func PublishRelease(version string, releaseId int64, uploadArtifacts *string) (e
5656
if releaseId == 0 {
5757
releaseIdStr, releaseIdBool := os.LookupEnv("ACI_RELEASE_ID")
5858
if !releaseIdBool {
59-
log.Fatalln("Not release found creating one...")
60-
CreateRelease(version, draftFalse)
61-
}
62-
releaseId, err = strconv.ParseInt(releaseIdStr, 10, 64)
63-
if err != nil {
64-
fmt.Printf("%s of type %T", releaseIdStr, releaseIdStr)
65-
os.Exit(2)
59+
log.Println("No release found, creating one...")
60+
release, err := CreateRelease(version, false)
61+
if err != nil {
62+
log.Fatalln(err)
63+
}
64+
releaseId = *release.ID
65+
} else {
66+
releaseId, err = strconv.ParseInt(releaseIdStr, 10, 64)
67+
if err != nil {
68+
fmt.Printf("%s of type %T", releaseIdStr, releaseIdStr)
69+
os.Exit(2)
70+
}
6671
}
6772
}
6873

@@ -92,10 +97,10 @@ func PublishRelease(version string, releaseId int64, uploadArtifacts *string) (e
9297
return err
9398
}
9499

95-
for _, fileAndInfo := range filesAndInfos {
100+
for i, fileAndInfo := range filesAndInfos {
96101
fmt.Printf("uploading %s as asset to release", fileAndInfo.Name)
97102
// Upload assets to GitHub Release
98-
_, _, err := GithubClient.Repositories.UploadReleaseAsset(
103+
relAsset, _, err := GithubClient.Repositories.UploadReleaseAsset(
99104
ctx,
100105
owner,
101106
repo,
@@ -106,6 +111,17 @@ func PublishRelease(version string, releaseId int64, uploadArtifacts *string) (e
106111
&fileAndInfo.File)
107112
if err != nil {
108113
log.Println("error at uploading asset to release: ", err)
114+
} else {
115+
// export Download URL to env. See: #53
116+
envVars, err := OpenEnvFile()
117+
if err != nil {
118+
log.Println("could open envs:", err)
119+
}
120+
envVars.Set(fmt.Sprintf("ACI_ARTIFACT_%d_URL", i+1), *relAsset.BrowserDownloadURL)
121+
err = envVars.SaveEnvFile()
122+
if err != nil {
123+
log.Println("could not export atrifact url:", err)
124+
}
109125
}
110126
}
111127
}

tests/github_env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ ACI_VERSION=0.7.7
88
ACI_LATEST_VERSION=0.7.6
99
ACI_OWNER=fullstack-devops
1010
ACI_REPO=awesome-ci
11-
ACI_RELEASE_ID=57228901
11+
ACI_RELEASE_ID=57778494
12+
ACI_ARTIFACT_0_URL=https://github.com/eksrha/playground/releases/download/2.0.0/awesome-ci

0 commit comments

Comments
 (0)