Skip to content

Commit

Permalink
Release node package (#7)
Browse files Browse the repository at this point in the history
* Update README.md

* publish node package

* publish node package

* Update release.yml

* Update release.yml

* Update release.yml

* Update release.yml

* release.yml

* release.yml

* release.yml

* setup node package

* yarn setup node package

* fix scope

* try npm publish

* print npmrc

* try moving npmrc

* try moving npmrc

* try moving npmrc

* try moving npmrc

* try no private

* dont move npmrc

* set version with jq

* set version with jq

* remove duplicate

* use tag as version

* use tag as version

* use tag as version

* Update README.md

* Update README.md

* Update release.yml

* add missing {

Co-Authored-By: Marcelo Luiz Onhate <[email protected]>

* fix typos

Co-authored-by: Marcelo Luiz Onhate <[email protected]>
  • Loading branch information
roni-frantchi and onhate authored Jan 23, 2020
1 parent 3605d9c commit 4767bbe
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 19 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ jobs:
- name: Build project
run: |
go build
mkdir out
go build -o ./out/terratag/terratag
- name: Create Release
id: create_release
uses: actions/[email protected]
Expand All @@ -38,14 +39,33 @@ jobs:
release_name: Terratag ${{ github.ref }}
draft: false
prerelease: false


# Setup .npmrc file to publish to GitHub Packages
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@env0'

- run: |
npm init --yes --scope @env0
ref=${{ github.ref }}
tag=\"${ref#"refs/tags/v"}\"
echo "`jq .version="${tag}" package.json`" > package.json
working-directory: ./out/terratag
# Need to get version from release
- run: npm publish ./out/terratag
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./terratag
asset_path: ./out/terratag/terratag
asset_name: terratag-linux
asset_content_type: application/zip
44 changes: 29 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@ Add tags to your AWS resources in both Terraform 0.11 and 0.12!
## Prerequisites
- [tfschema](https://github.com/minamijoyo/tfschema) to assert which resources support `tags` in AWS Provider
- Terraform 0.11 or 0.12
- Go > 1.13.5

## Build
```bash
go get
go build
```

## Usage
Terratag recives two commaind line arguments:
- `-dir` - optional, the directory to recursively search for any `.tf` file and try to terratag it.
- `-tags` - tags, as valid JSON (NOT HCL)
1. Download the latest [release binary](https://github.com/env0/terratag/releases) or install the latest [node package](https://github.com/env0/terratag/packages)
2. ```bash
terraform init # needed to initialize provider schema and pull child terraform modules
terratag -dir=foo/bar -tags={\"hello\": \"world\"}
```
> Note Terratag receives two command line arguments:
> - `-dir` - optional, the directory to recursively search for any `.tf` file and try to terratag it.
> - `-tags` - tags, as valid JSON (NOT HCL)

```bash
terraform init # needed to initialize provider schema and pull child terraform modules
terratag -dir=foo/bar -tags=\"hello\": \"world\"} # (or go run . -dir=... -tags=...)
```

## Notes
- Only AWS resources are supported (for now)
Expand All @@ -39,10 +33,30 @@ Instead, `terratag` uses HashiCorps' [`hclwrite`](https://godoc.org/github.com/h
```
`tfschema` can't find your AWS Provider schema - You probably didn't run `terraform init`
## Develop
### Prerequisites
- Go > 1.13.5
### Build
```bash
git clone https://github.com/env0/terratag
go get
go build
```
### Release
```bash
# release tags have to start with v to trigger the release workflow -
# https://github.com/env0/terratag/blob/master/.github/workflows/release.yml
git tag vx.x.x
git push --tags
```
## TODO
- [ ] Support for resource block nested in for loops (?)
- [ ] Add godocs
- [ ] Add unit tests
- [ ] Remove `tfschema` as a prerequsite install
- [ ] Automate and publish package release binaries
- [x] Automate and publish package release binaries
- [ ] Support tagging resources in `.tf.json` files (?)

0 comments on commit 4767bbe

Please sign in to comment.