Skip to content

Commit 5eff559

Browse files
authored
Merge pull request #153 from Automattic/experiement/changelog
2 parents 83bbac2 + 9cadcfd commit 5eff559

File tree

5 files changed

+80
-83
lines changed

5 files changed

+80
-83
lines changed

.github/workflows/changelog.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Replaces the `<!-- changelog -->` comment in the README.md with the release notes from GitHub.
2+
// Usage locally:
3+
// TOKEN=... GITHUB_REPOSITORY='Automattic/ad-code-manager' node .github/workflows/changelog.js
4+
// Where TOKEN is a personal GitHub token that has access to the repo: https://github.com/settings/tokens
5+
// In a GitHub Workflow, TOKEN can be passed the special ${{ secrets.GITHUB_TOKEN }} token.
6+
7+
const github = require('@actions/github');
8+
const semver = require('semver');
9+
const replace = require('replace-in-file');
10+
11+
const filename = process.argv[2] || 'README.md';
12+
const myToken = process.env.TOKEN;
13+
14+
async function run() {
15+
const api = new github.GitHub(myToken);
16+
17+
const { data: releases } = await api.repos.listReleases( github.context.repo );
18+
19+
let published = releases.filter( release =>
20+
! release.draft && ! release.prerelease
21+
);
22+
23+
let sorted = published.sort( ( a, b ) =>
24+
semver.rcompare( semver.coerce( a.tag_name ), semver.coerce( b.tag_name ) )
25+
);
26+
27+
let changelog = sorted.reduce( ( changelog, release ) =>
28+
`${changelog}
29+
30+
### ${release.tag_name}
31+
32+
${release.body}`
33+
, '## Changelog' );
34+
35+
try {
36+
const results = await replace( {
37+
files: filename,
38+
from: '<!-- changelog -->',
39+
to: changelog,
40+
} );
41+
42+
if ( results.filter( result => ! result.hasChanged ).length ) {
43+
console.error( 'No replacements made' );
44+
process.exitCode = 1;
45+
}
46+
} catch( exception ) {
47+
console.error( exception );
48+
process.exitCode = 1;
49+
}
50+
}
51+
52+
run();

.github/workflows/deploy.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@ jobs:
77
name: New tag
88
runs-on: ubuntu-20.04
99
steps:
10-
- uses: actions/checkout@v3
10+
- name: Checkout repository
11+
uses: actions/checkout@v3
12+
13+
- name: Configure NPM cache
14+
uses: c-hive/gha-npm-cache@v1
15+
16+
- name: Install Dependencies
17+
run: npm install
18+
19+
- name: Populate Changelog
20+
run: node .github/workflows/changelog.js
21+
env:
22+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
1123

1224
- name: WordPress Plugin Deploy
1325
uses: 10up/action-wordpress-plugin-deploy@stable

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.phpunit.result.cache
22
/composer.lock
3+
/package-lock.json
34
/vendor

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "ad-code-manager",
3+
"version": "0.5.0",
4+
"description": "Easy ad code management.",
5+
"license": "GPL-2.0-or-later",
6+
"author": "Automattic",
7+
"repository": "automattic/ad-code-manager",
8+
"devDependencies": {
9+
"@actions/github": "^2",
10+
"replace-in-file": "^5",
11+
"semver": "^7"
12+
}
13+
}

readme.md

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -551,85 +551,4 @@ function my_acm_ad_code_args( $args ) {
551551
}
552552
~~~
553553
554-
## Upgrade Notice
555-
556-
### 0.5
557-
DFP Async provider now supports multiple sizes. [Check out this snippet to see implementation](http://pastie.org/10422227)
558-
559-
### 0.4
560-
Easier, streamlined configuration for Doubleclick for Publishers Async and Google AdSense.
561-
562-
### 0.3
563-
Conditional operator logic can be set on an ad code by ad code basis. Couple of bug fixes.
564-
565-
### 0.2.3
566-
The filter acm_provider_columns is removed in favor of acm_ad_code_args (see acm_ad_code_args )
567-
568-
### 0.2.2
569-
Incorporated a new provider for Google AdSense and added bulk delete action for the WP List Table.
570-
571-
### 0.2.1
572-
Flush the cache when adding or deleting ad codes, and set priority of 10 when a priority doesn't exist for an ad code.
573-
574-
## Changelog
575-
576-
### 0.5 (Sep 15, 2015)
577-
* Added support for flex sized DFP Async ads (see upgrade notice)
578-
* Added robots.txt entries for provider's crawlers
579-
* Bug fix: Prevent global `$post` polution if ad code is getting rendered inside a loop
580-
* New Italian translation courtesy of [sniperwolf](https://github.com/sniperwolf)
581-
* Using PHP5 constructs when initializing the widget
582-
583-
### 0.4.1 (Apr. 27, 2013)
584-
* Disabled rendering of ads on preview to avoid crawling errors. Thanks [Paul Gibbs](https://github.com/paulgibbs)
585-
* Bug fix: Corrected "medium rectangle" ad size for DFP Async Provider. Thanks [Marco](https://github.com/NRG-R9T)
586-
587-
### 0.4 (Mar. 19, 2013)
588-
* Streamlined configuration for Doubleclick for Publishers Async and Google AdSense
589-
* Faster, cleaner JavaScript thanks to [Jeremy Felt](https://github.com/jeremyfelt) and [Carl Danley](https://github.com/carldanley)
590-
* New filter 'acm_output_html_after_tokens_processed' for rare cases where you might want to filter html after the tokens are processed
591-
592-
### 0.3 (October 25, 2012)
593-
* Conditional operator logic can be set on an ad code by ad code basis. Thanks [jtsternberg](https://github.com/jtsternberg) for the pull request!
594-
* Bug fix: If an ad tag doesn't need a URL, ignore the whitelist check
595-
* Bug fix: Make sure that all providers list tables call parent::get_columns to avoid conflicts with filters.
596-
* Coding standards cleanup
597-
598-
### 0.2.3 (June 25,2012)
599-
* Allow columns to be optional when creating and editing ad codes, introduced new filter acm_ad_code_args
600-
* Remove acm_provider_columns filter
601-
602-
### 0.2.2 (June 5, 2012)
603-
* New Google Ad Sense provider courtesy of [Erick Hitter](http://www.ethitter.com/)
604-
* Bulk delete action added for the WP List Table of ad codes. Delete more ad codes in one go
605-
* New 'acm_register_provider_slug' for registering a provider that's included outside the plugin (e.g. a theme)
606-
* Bug fix: Instantiate the WP List Table on the view, instead of on admin_init, to reduce conflicts with other list tables
607-
608-
### 0.2.1 (May 14, 2012)
609-
* Flush the cache whenever an ad code is created or deleted so you don't have to wait for a timeout with persistent cache
610-
* Bug fix: Default to priority 10 when querying for ad codes if there is no priority set
611-
612-
### 0.2 (May 7, 2012)
613-
* UI reworked from the ground up to look and work much more like the WordPress admin (using WP List Table)
614-
* Abstracted ad network logic, so users can integrate other ad networks. Pull requests to add support to the plugin are always welcome
615-
* Added in-plugin contextual help
616-
* Implemented priority for ad code (allows to workaround ad code conflicts if any)
617-
* Implemented the [acm-tag] shortcode
618-
* Implemented ACM Widget. Thanks to [Justin Sternburg](https://github.com/jtsternberg) at WebDevStudios for the contribution
619-
* Initial loading of the ad codes is now cached using object cache
620-
* Bug fix: Enable using ad codes with empty filters using a filter
621-
* Bug fix: Setting the logical operator from OR to AND did not seem to result in the expected behaviour for displaying ads
622-
* Bug fix: Remove logical operator check when a conditional for an ad code is empty
623-
624-
### 0.1.3 (February 13, 2012)
625-
* UI cleanup for the admin, including styling and information on applying conditionals
626-
627-
### 0.1.2 (February 9, 2012)
628-
* Readme with full description and examples
629-
* Bug fix: Save the proper value when editing actions
630-
631-
### 0.1.1
632-
* Bug fix release
633-
634-
### 0.1
635-
* Initial release
554+
<!-- changelog -->

0 commit comments

Comments
 (0)